PDA

View Full Version : javascript:


crilly
03-25-2003, 07:17 PM
I just discovered, after upgrading to IE SP1 that many of my Javascripts no longer work. Commands prefaced by "Javascript:" work, while those that are no prefaced no longer work. I searched posts but couldn't find anything on this problem. Have others encountered this? Is there a way of dealing with it other than modifying thousands and thousands of lines of HTML? Many thanks!

Vladdy
03-25-2003, 07:20 PM
Write compliant HTML to begin with....

crilly
03-26-2003, 02:47 AM
Are you stating that in order to be compliant to the HTML standard that ALL javascript commands must be prefaced by "Javascript:"?

glenngv
03-26-2003, 02:54 AM
events handlers are not prefaced with javascript: since the default scripting language is javascript, only on attributes like href in anchor tags and action in form tags. can you post some codes that you said were not working?

crilly
03-26-2003, 03:50 AM
Both the following samples of code worked fine last week. Now, only the first sample works (upgraded IE). Any explanations? Greatly appreciate your help!

href="javascript:showHelp('../HELPfiles/Request/REQ3requestHeader.htm')

href="#" onClick="showHelp('../HELPfiles/Request/REQ8itemsDetails.htm')

glenngv
03-26-2003, 03:57 AM
what really happens when you said that it is not working? is there any error msg?

try putting return false at the end of onclick (though it is not the cause of the problem). maybe it would help if you post the showHelp() function.

href="#" onClick="showHelp('../HELPfiles/Request/REQ8itemsDetails.htm');return false"

crilly
03-26-2003, 04:06 AM
Good suggestion, but I don't think it would help. The truth is, when I click on the link, NOTHING happens. Not even a screen refresh. The function is simply not executing. Nothing.

glenngv
03-26-2003, 05:47 AM
did you try putting an alert inside the function to see if it is called? Make sure also that error notification is turned on (if you're using IE) to see if there's really no error produced.

Roy Sinclair
03-26-2003, 06:21 PM
Show more of your code, the fragments you posted so far excepting the missing "return false;" look fine and I've not seen any version of IE fail to handle. Perhaps the problem exists in the function you're calling and not where you're calling the code.

Most importantly, if you want to call yourself a developer you must turn on the reporting of javascript errors (Tools > Internet Options > Advanced > Display a notification about every script error). Without that option turned on you only get the little icon in the lower left hand corner of the page to indicate an error occured and you'll miss more errors than you'll catch.

crilly
03-27-2003, 04:34 PM
Here's the showHelp function:
function showHelp(theURL)
{
newWin = window.open(theURL, 'HoboHelp', 'toolbar=yes,scrollbars=yes,resizable=yes,width=520,height=200');
newWin.focus();
return false;
}

As you can see, it's very simple, and does embed the "return false" check. However, as I've stated before, the function is simply not being called. And error message notification IS turned on.

PS Why do some on this site make statements such as, "...if you want to call yourself a developer you must..." or "Write compliant HTML to begin with..." I thought this was a site for adults with some maturity!

brothercake
03-27-2003, 04:41 PM
Originally posted by crilly
Why do some on this site make statements such as, "...if you want to call yourself a developer you must..." or "Write compliant HTML to begin with..." I thought this was a site for adults with some maturity!
It's a common trait among web developers - once you've made the jump from proprietary to standards-compliant coding, it's very easy to be glib. I'm sometimes guilty of this myself.

But all the same - standards compliance *is* a form of programming maturity; I believe that Vladdy was simply making this point - if you start with compliant code, errors crop up less often and are easier to debug when they do. What probably made him think to say that is that you referred to a "Javascript" pseudo-protocol, when the correct syntax is "javascript" (lower case). Simple things like this are often code-breakers.

Anyway - can you post a link to a webpage which illustrates the complete problem you're having - it would be a lot easier for us to see what's going on.

joh6nn
03-27-2003, 05:03 PM
i'm inclined to think it's SP1 that's the problem, and not your code. just after i upgraded to SP1, a lot of my code became "buggy" as well (specifically, window.open() stopped working), even though it continued to work fine on other machines, and even in other browsers on my own machine. after a while, the problem went a way, but i can't tell you what i did, if anything, that fixed it.

anyway, test your pages in other browsers, or on other machines, to see if the code is faulty, or if SP1 is.

Roy Sinclair
03-27-2003, 08:03 PM
Well I can see one problem with the way you call showHelp from the onclick event.

You have:

href="#" onClick="showHelp('../HELPfiles/Request/REQ8itemsDetails.htm')

it should be:

href="#" onClick="return showHelp('../HELPfiles/Request/REQ8itemsDetails.htm')"

Some versions of browsers will autmatically assume you meant to use the value returned from a function and pass it to the browser while other versions don't make such an assumption and could end up sending anything tjey like on. Explicitly specifying that the return value from the function is to be used eliminates the ambiguity.

crilly
03-27-2003, 08:22 PM
Appreciate your explanation. Can't give you a link to the site--it's a departmental Intranet site for handling procurement and payment transactions. Throughout the pages of this application, various labels are hyperlinked to context-sensitive help pages. On the html pages using the first syntax:

href="javascript:showHelp('../HELPfiles/Request/REQ3requestHeader.htm')

the help pages display normally. On the pages using the second syntax:

href="#" onClick="showHelp('../HELPfiles/Request/REQ8itemsDetails.htm')

the help pages do not. Prior to my browser (IE) upgrade, both pages worked perfectly. We could simply re-write the broken pages to use the syntax that works (and we will), but we'd like to understand the problem as well, incase it may crop up elsewhere. Appreciate your help!

PS I'm not the developer, so any mistakes I make in syntax are due to admitted ignorance...

brothercake
03-27-2003, 10:49 PM
Well I have IE6 SP1 and your second syntax works fine for me, as it should; this is the darnest thing ...

RoyW
03-27-2003, 11:10 PM
Maybe you could cut'n'paste the code for a whole <a> tag that doesn't work.

Also,
Try this
<a href="#" onClick="alert(1);return showHelp('../HELPfiles/Request/REQ8itemsDetails.htm')">Click me</a>

This will test if the onClick is working.

Does SP1 have any popup blocker software included?

Does onclick work instead of onClick?

crilly
03-28-2003, 01:40 AM
I have IE version 6.0.2800.1106
Update versions: SP1;Q810847

Does that match your version?

brothercake
03-28-2003, 11:57 PM
Same version - 6.0.2800.1106

And update versions SP1; Q328970; Q324929; Q810847;

The last one is the same, presumably latest?