IE javascript:function() link error

S

steephill.tv

Some windows IE users encounter an error when launching javascript
from my links. An error is generated before the window opens.
For example:

<a href="javascript:playCosmos('pr-08-highlights-eurosport','7385866',
13,4,2008);">One Minute Race Highlights from Paris-Roubaix</a>

function PlayCosmos(title, id, day, month, year) {
url = 'http://cosmos.bcst.yahoo.com/up/player/popup/index.php?
cl='+id;
NewWindow(url,title,430,426,'no');
}

function NewWindow(mypage, title, w, h, scroll) {
OpenWindow(mypage, title, w, h, scroll);
win.window.focus();
}

function OpenWindow(mypage, title, w, h, scroll) {
var winl = parseInt((window.screen.width - w) / 2);
var wint = parseInt((window.screen.height - h) / 2);
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl
+',scrollbars='+scroll+',resizable=no';
win = window.open(mypage, title, winprops);
}


Anyone know why?

There are other variations of javascripts links that don't work in my
"Cycling video clip of the day" section on my home page:
http://www.steephill.tv

tia,
Steve
 
R

RobG

Some windows IE users encounter an error when launching javascript
from my links. An error is generated before the window opens.
For example:

<a href="javascript:playCosmos('pr-08-highlights-eurosport','7385866',
13,4,2008);">One Minute Race Highlights from Paris-Roubaix</a>

It does not seem sensible to create a reliance on script support when
it isn't necessary.

function PlayCosmos(title, id, day, month, year) {
url = 'http://cosmos.bcst.yahoo.com/up/player/popup/index.php?
cl='+id;
NewWindow(url,title,430,426,'no');
}

Consider instead (will break on wrapping):

<a href="http://cosmos.bcst.yahoo.com/up/player/popup/index.php?
cl=7385866"
onclick="return playCosmos(this, 'pr-08-highlights-eurosport',
'7385866',
13,4,2008);"

And the playCosmos function can be modified to suit, something like:

function playCosmos(link, title, id, day, month, year) {
NewWindow(link.href, title,430,426,'no');
return false;
}

Now if the user has scripting disabled or not available, or the script
fails to execute correctly, there's still a good chance they can view
the clip and you've reduced your support requirements.

A couple of comments:
1. Why use 3 functions where one would do?
2. It is usual to reserve functions names starting with capital
letters for constructors.
3. Don't try to position the pop-up, let it go where the user puts
it. Consider someone with a desktop spread over two screens, your pop-
up will be split between the two. Also, users with large or wide
screens probably don't want a small movie in the center of the screen.
 
S

steephill.tv

A couple of comments:

I'm using a javascript as an anchor because the page will become
invalid in three months and I'll either redirect the user to another
page or I'll provide a user-friendly message. In other words, I want
control the implementation.

I appreciate your detailed feedback, but you didn't address my
question. Why doesn't the script work? Anyone know why?
 
T

Thomas 'PointedEars' Lahn

I'm using a javascript as an anchor because the page will become
invalid in three months and I'll either redirect the user to another
page or I'll provide a user-friendly message. In other words, I want
control the implementation.
http://www.w3.org/Provider/Style/URI

I appreciate your detailed feedback, but you didn't address my
question. Why doesn't the script work? Anyone know why?

Because it can't. The `javascript:' URI scheme exists to return an HTML
document string from a JavaScript expression. Neither does this need to be
supported nor are you returning a HTML document string from PlayCosmos().


PointedEars
 
S

steephill.tv

Because it can't.  The `javascript:' URI scheme exists to return an HTML
document string from a JavaScript expression.  Neither does this need tobe
supported nor are you returning a HTML document string from PlayCosmos().

PointedEars

Thanks for your answer. So why does this example from a Javascript
reference site work:
http://www.web-source.net/javascript_popup_window2.htm

So should I return an empty string from PlayCosmos or should it be
launched by the onclick event handler of the anchor?

thanks,
Steve
 
T

Thomas 'PointedEars' Lahn

A couple of comments:
I appreciate your detailed feedback, but you didn't address my
question. Why doesn't the script work? Anyone know why?
Because it can't. The `javascript:' URI scheme exists to return an HTML
document string from a JavaScript expression. Neither does this need to be
supported nor are you returning a HTML document string from PlayCosmos().
[...]

Thanks for your answer. So why does this example from a Javascript
reference site work:
http://www.web-source.net/javascript_popup_window2.htm

If any such example works, then that should be considered a happy coincidence.

This site does not deserve to be called a "Javascript reference site",
whatever your understanding of the word "Javascript". It promotes invalid
markup, obsolete techniques, and content that does not degrade gracefully
(i.e. is in violation of Section 508 and other accessibility guidelines and
legislation), to say the least. And one can find that out by just looking
at the example that you referred to. Guess what abominations of failed
attempts at Web application development other parts of it might reveal ...
So should I return an empty string from PlayCosmos or should it be
launched by the onclick event handler of the anchor?

You should do what Rob already recommended.


PointedEars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top