By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,287 Members | 1,665 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,287 IT Pros & Developers. It's quick & easy.

IE javascript:function() link error

P: n/a
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
Jun 27 '08 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On Apr 16, 7:21 am, steephill...@gmail.com wrote:
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.
--
Rob
Jun 27 '08 #2

P: n/a
>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?


Jun 27 '08 #3

P: n/a
st**********@gmail.com wrote:
>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.
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
Jun 27 '08 #4

P: n/a
On Apr 16, 5:24*pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
wrote:
steephill...@gmail.com wrote:
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.

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 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
Jun 27 '08 #5

P: n/a
st**********@gmail.com wrote:
[...] Thomas 'PointedEars' Lahn [...] wrote:
>steephill...@gmail.com wrote:
>>>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
--
Prototype.js was written by people who don't know javascript for people
who don't know javascript. People who don't know javascript are not
the best source of advice on designing systems that use javascript.
-- Richard Cornford, cljs, <f8*******************@news.demon.co.uk>
Jun 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.