/    Sign up×
Community /Pin to ProfileBookmark

Script works for some, for others it doesn’t… Please help!

Hello All,

please help me solve a problem with my script… Some people say it works, while others say it doesn’t… I am simply at a loss (admittedly, because I am really new to JavaScript).

Anyway, the script is on a parent page, it resizes it on load, and then opens and also resizes a new window with a calendar when people click on the word “calendar” on that parent page. It works just fine for me and many others as well, but some people tell me that they get Java errors when they click on the word “calendar”.

The script goes like this:


——————————————–

<body onLoad=”javascript:move_2_200_0();”>

<script language=”JavaScript”>
<!–
function move_2_200_0()
{
self.moveTo(200,0)
self.resizeTo(700,700)
}
function open_new_window(url)
{
new_window = window.open(url, ‘Calendar’,’toolbar=0,menubar=0,resizable=0,dependent=0,status=0,width=250,height=220,left=700,top=120′)
}
//–>
</script>

<a href=”javascript:open_new_window(‘ENG/calendar_EN.html’);” target=”_blank”>calendar</a>
——————————————–

What I so far tried to do to find the cause of the error was this:

1) replaced the line ‘ENG/calendar_EN.html’ with its full [url]http://[/url] path – no effect (works fine for me just as before but not for those who coudn’t open that calender earlier either). The page “calendar_EN.html” is indeed in the same directory (“ENG”) with its parent page.

2) repalced the “url” in brackets with the full [url]http://[/url] address – stopped working even for me

3) tried to replace single quotes around ‘ENG/calendar_EN.html’ with &quot – no go either…

Does anyone see a problem in my script? If so, what ist it? Why does it work for some people and doesn’t for others??? I would greatly appreciate any help and advice!

Also, and while at it… I somehow sense that the problem is either with the function open_new_window or javascript:open_new_window(‘xxxxxxx’), or both…

What I basically want to do (and would also very much prefer to do it this way) is this:

I would like to have a simple <a href …….. </a> link to the word “calendar” on the parent page while placing all the self.move and self.resize stuff onto the page called for through this link (i.e., the page containing the calendar), and thus get rid of this (so far half working, half not) open_new_window thing on the parent page.

But then, if I place the self.move and self.resize things on the child page, how do I tell it not to show the toolbar, menubar, directories, etc., etc. from within this page and not from the parent page???

If this is all possible, how do I do it?

Millions of thanks in advance for any help!

Valery

to post a comment
JavaScript

21 Comments(s)

Copy linkTweet thisAlerts:
@ValeryauthorDec 21.2002 — PS: I have no idea how those silly smilies managed to get into my message... I suspect they were inserted automatically in place of a "colon" followed by an "o"... Sorry for that anyway.
Copy linkTweet thisAlerts:
@CharlesDec 21.2002 — [font=georgia]On my browser neither the resizing of my window nor the 'calendar' link will work. The former is just fine with me - I cannot stand web authors messing with my windows - but the link to nowhere is a problem. Try instead:

[font=monospace]

<a href="ENG/calendar_EN.html" onclick="window.open(this.href, 'calendar', 'width=250, height=220, left=100, top=120, screenX=100, screenY=120'); return false">Calendar</a>

[/font]

And note, the people who are getting an error might be people with screens that are less than 700px wide. [/font]
Copy linkTweet thisAlerts:
@ValeryauthorDec 21.2002 — Charles,

thank you very much indeed for your prompt reply and for your great help! It works alright now!!! Wow! Many many thanks again!

Like they say, no good deed remains unpunished... so please allow me to torture you with another couple of questions:

1) In the variable you suggested to me I have changed the positioning of the calendar to left=0, top=0, so that it doesn't cover any part of its parent page. How do I place it into the upper _right_ corner of the screen (without knowing the screen size of the user)?

2) These two things screenX=100 and screenY=120 in the variable you suggested to me seem to have no effect - why? Still leave them there?

3) I have commented out these things in my previous script

//function open_new_window(url)

//{

//new_window = window.open(url, 'Calendar','toolbar=0,menubar=0,resizable=0,depend

//ent=0,status=0,width=250,height=220,left=700,top=1

//20')

//}

and everything still works perfectly. Can I safely delete them completely?

4) Offline (while in DreamWeaver) the path to the calendar 'ENG/calendar_EN.html' works OK, but when I uploaded the page, the calendar could not be found... So I had to modify the path to look like this - '../ENG/calendar_EN.html'

Which would be the most reliable way for the calendar to be found - '../ENG/calendar_EN.html' or 'http://my_site.com/ENG/calendar_EN.html' ?

5) You are absolutely right in that you say I have to also think about people with screens less than 700 px (my screen is 15" and it looks just fine on it). The parent page (from which the calendar is called) is about 600 px wide and 700 px high. I certainly don't want to mess with peoples' windows but would simply like to position this parent window neatly in the middle of their screens for a better presentation - say, top=10, left= what??? What would you suggest?

Lots and lots of thanks yet again!

Valery
Copy linkTweet thisAlerts:
@CharlesDec 21.2002 — [font=georgia]1) You can know the size of a user's screen if the user has a screen and if the user is using JavaScript, but it gets a little ugly. Thus:

[font=monospace]

<a href="ENG/calendar_EN.html">Calendar</a>

<script type="text/javascript">

<!--

param = 'width=250, height=100, top=0, screenX=0';

param += ',left=';

param += Screen.availWidth-250;

param += ',screenX=';

param += Screen.availWidth-250;

document.links[document.links.length-1].onclick = function () {window.open(this.href, 'calendar', param); return false};

// -->

</script>

[/font]

2) Microsoft recognizes 'top' and 'left', Netscape 'screenY' and 'screenX'.

3) Be done with it.

4) That's odd. But do what works and know the relative and absolute paths work equally well.

5) I would suggest that you get rid of all this JavaScript nonsense and let people's screens alone. If they want something in a new window then they know how to get it there. And no good ever comes of resizing or moving people's windows. [/font]
Copy linkTweet thisAlerts:
@swonDec 21.2002 — Another solution is following script. It works fine in most of the browsers:

<script language="JavaScript">

<!--

function winopens(url)

{

var winwidth = "400"; // your windowopen width;

var y = screen.availWidth; // width of screen

var right = y-winwidth;

var w = window.open(url,'yourwindowname','width='+winwidth+',height=250'); // opens the window;

w.moveTo(right,0); // 1st is left, 2nd is top

}

//-->

</script>

<a href="sample.html" onClick="winopens(this.href);return false">open</a>
Copy linkTweet thisAlerts:
@CharlesDec 21.2002 — [font=georgia]True, but it can cause flashing. Some users will see the window in its original position for just an instant before it is moved. And there is an error in my script above. As swon has noted, it should be [font=monospace][b]s[/b]creen.availWidth[/font][/font]
Copy linkTweet thisAlerts:
@ValeryauthorDec 21.2002 — Charles and Swon,

thank you so much for your replies anf for your very interesting suggestions!!!

I will certainly check it all out ... have to digest it first :-)


---------------------------

Swon, please tell me, do I have to replace (url) with my page's real URL in your script?

<script language="JavaScript">

<!--

function winopens(url) <--- e.g. here ???

{

etc., etc.


Lots of thanks to both of you again!


Valery
Copy linkTweet thisAlerts:
@swonDec 21.2002 — No, that's an variable, generated by the a href of your link:

<a href="[B]sample.html[/B] " onClick="winopens([B]this.href[/B]);return false">open</a>

you must only change the sample.html !
Copy linkTweet thisAlerts:
@ValeryauthorDec 21.2002 — Oh, I see... Thank you Swon!

I also read somewhere of a possibility of a so called "hover window"... Do you think it would work in my case or would it only complicate things?

Many thanks again!


Valery
Copy linkTweet thisAlerts:
@ValeryauthorDec 21.2002 — PS:

Charles and Swon,

forgot to ask you both... The new scripts you just suggested to me, where do they go? Beteween <head> and </head> or <body> and </body>?

Thank you again!


Valery
Copy linkTweet thisAlerts:
@swonDec 21.2002 — Put it between <head>and</head> for a better overview.
Copy linkTweet thisAlerts:
@ValeryauthorDec 21.2002 — Thank you, Swon!


Valery
Copy linkTweet thisAlerts:
@CharlesDec 21.2002 — [i]Originally posted by Valery [/i]

[B]PS:



Charles and Swon,



forgot to ask you both... The new scripts you just suggested to me, where do they go? Beteween <head> and </head> or <body> and </body>?



Thank you again!





Valery [/B]
[/QUOTE]
[font=georgia]Swon's method and my method are very different. The fragment:

[font=monospace]

<a href="ENG/calendar_EN.html">Calendar</a>

<script type="text/javascript">

<!--

param = 'width=250, height=100, top=0, screenX=0';

param += ',left=';

param += Screen.availWidth-250;

param += ',screenX=';

param += Screen.availWidth-250;

document.links[document.links.length-1].onclick = function () {window.open(this.href, 'calendar', param); return false};

// -->

</script>

[/font]

is a unit. Don't split it up and put it where you would the link.[/font]
Copy linkTweet thisAlerts:
@ca_redwardsDec 26.2002 — I have created a free fully-navigable cross-browser pop-up calendar in less than 4K! See [URL=http://www.angelfire.com/ca/redwards/html__.calendar.html]http://www.angelfire.com/ca/redwards/html__.calendar.html [/URL] for details.
Copy linkTweet thisAlerts:
@swonDec 26.2002 — [B]:Here's a calendar script that works for any browser that supports JavaScript 1.2 [/B]

I have created a free fully-navigable cross-browser pop-up calendar in less than 4K! See http://www.angelfire.com/ca/redwards/html__.calendar.html for details.



Not bad, but my browser (IE6) gives me an Error on line one --- 1181 by clicking the calendar.
Copy linkTweet thisAlerts:
@ValeryauthorDec 26.2002 — [i]Originally posted by ca_redwards [/i]

[B]I have created a free fully-navigable cross-browser pop-up calendar in less than 4K! See [URL=http://www.angelfire.com/ca/redwards/html__.calendar.html]http://www.angelfire.com/ca/redwards/html__.calendar.html [/URL] for details. [/B][/QUOTE]


[i]In the calendar example above, here is the code that builds the empty calendar: [/i]

[B] h=(m.OPTION().SELECT(NAME('m'))+INPUT(TYPE('text')+SIZE(4)+NAME('y'))+INPUT(TYPE('hidden')+NAME('date'))).TD(ALIGN('center'));

r=new Array(7).INPUT(TYPE('button')+NAME('d')+STYLE('width:'+sz+';height:'+sz)).TD(ALIGN('right')+WIDTH(sz*7)+HEIGHT(sz));

h=[h,r,r,r,r,r,r,r].TR().TABLE(BORDER('0')+CELLSPACING('0')+CELLPADDING('0')).FORM(NAME('frm'));



Above, an array of month names is built into select list m, which is concatenated with textbox y and hidden field date, before inclusion in a single table cell. Then, each of r's seven empty elements are defined as square buttons named d, and included in another table cell. Finally, h and seven copies of r (in an unnamed array) are defined as distinct table rows, included into a single table, for inclusion into form frm. [/B]
[/QUOTE]



Hi, ca_redwards,


I have read the above as well as the rest of the text on the page you've indicated above... Then I tried to read Confucius (in original) and found the latter much more comprehensible - at least for me. Otherwise it's probably a nice calendar...

Thanks anyway!

Valery
Copy linkTweet thisAlerts:
@ca_redwardsDec 26.2002 — What is the error? Can you quote its exact text...

That'd help me track it down.
Copy linkTweet thisAlerts:
@ca_redwardsDec 26.2002 — Valery,

What is "Confucius" in you message refer to?

If you had any error after clicking the first two links on my calendar page, please let me know. Thanks!
Copy linkTweet thisAlerts:
@CharlesDec 26.2002 — [i]Originally posted by ca_redwards [/i]

[B]Valery,



What is "Confucius" in you message refer to?



If you had any error after clicking the first two links on my calendar page, please let me know. Thanks! [/B]
[/QUOTE]
[font=georgia]See http://zhongwen.com/rujia.htm.[/font]
Copy linkTweet thisAlerts:
@ca_redwardsDec 26.2002 — Valery,

My explanation is confusing? Is that what you're saying?

Well, I guess I agree. The script that builds the pop-up calendar is kind of complex...

But here's another attempt to explain it more simply:

The popup calendar has two parts to it. The first loads several JavaScript functions (154!) needed by the second part. The second part utilizes these functions to build and popup the calendar.

Initially, the calendar is built empty. Then some JavaScript updates the display with the current date, and enables the calendar navigation.

Change the month and year to see a new monthly calendar. Select a particular date to popup an alert depicting that date.
Copy linkTweet thisAlerts:
@ValeryauthorDec 27.2002 — Hello Richard,

[i]Originally posted by ca_redwards [/i]

[B] My explanation is confusing? Is that what you're saying?



... The script that builds the pop-up calendar is kind of complex... [/B]
[/QUOTE]


You bet... :-)


Now that you have explained how to use your calendar it became a bit clearer and I will check it out by all means.

To be frank, I wasn't actually looking for a new calendar - I already have one. What I asked here at the beginning of this thread was how to properly position that calendar on the user's screen and what JavaScript would open it without glitches I used to have before. Thanks to Charles and Swon the problem has been solved and I am more than happy with the results (Charles and Swon - are you listening? Many thanks again!).

But I will check yours anyway!

Thanks again,

Valery


-----------------------------------

PS: Charles, thanks you for stepping in re "what is Confucius"!
×

Success!

Help @Valery spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...