473,465 Members | 1,960 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

IE javascript:function() link error

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
5 1359
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
>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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Katja | last post by:
Hi all, I have a very bizarre problem. I have a button on a PHP page which I want to call a Javascript function when it is pressed. This is the code I have: echo "<td><a href='$a_row'...
1
by: Patrice | last post by:
Hi, I'm trying to use a javascript function passing a vb variable. I don't understand why it doesn't work. Can someone help me? Thanks in advance. Here is my javascript function used to...
1
by: Leila | last post by:
Hi folks, I have a fairly complex xml document which looks like this: <my:InsideView xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2004-08-02T14:22:59" xml:lang="en-us">...
5
by: lordslayer | last post by:
Helo! I have a little problem. My whole page (index.html) is based on one big table and an iFrame. In this iFrame one of the pages is a picture-thumbnail page. I found a javascript to open...
2
by: Kevin Lyons | last post by:
Hello, Can anyone assist me with what I am trying to do with the following code (six different scenarios to try to make the functionality work correctly)? I want to always (and ONLY) display...
5
by: elsenraat_76 | last post by:
Hello! I was wondering if someone could help me out with a problem I'm having? I'm trying to input a javascript value into an anchor tag (from a function), but don't have an event to call the...
1
by: jeff_m | last post by:
Hello all, I'm having an issue with the following: I have an .aspx page with two html links that call distinct Javascript functions. I also have an iframe in the html of this .aspx page....
4
by: verci | last post by:
Hi guys, I'm running asp.net 2.0. Does anyone know how to fire or call a javascript function from inside my (VB.aspx) code without assigning it to a control attribute? thank you
3
by: ravitunk | last post by:
hi..i have a javascript function which uses window.open() function to open another window... as below... <script language ="JavaScript"> function openWin(url) { ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.