You are currently viewing the Javascript section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
It depends what you're trying to do. You tend to get this error when you are trying to do something (usually involving a redirect - or at least, that's the classic case) that isn't actually supported by the HTTP protocol, for security reasons. There are all sorts of things involving redirects that could be used for Phishing-type attacks on users, if they were implemented within the hypertext protocol.
As was revealed in a recent thread on the PHP lists, redirection is one of the commonest ways in which all the major browsers (yes, Mozilla, too) fail to adhere properly to the standards. See:
ppewww.ph.gla.ac.uk/~flavell/www/post-redirect.html
(Sweet mother of Jesus - third edit! I'd like to see what genius came up with the script for munging URLs on this forum!
Don't just click on the link above, because the ASP scripts this site uses will leave the 'ppe' portion of the hostname off, in the above URL, and I can't work out how to stop it doing so. To summarise: the first portion of the URL above should read 'ppewww', not 'www', as the script seems to think, so just cut&paste the whole URL into a new browser address bar.)
All I am trying to do is to set the yes no value of a select menu equal to an array variable. Thoughts on the error?
Quote:
quote:Originally posted by Daniel Walker
It depends what you're trying to do. You tend to get this error when you are trying to do something (usually involving a redirect - or at least, that's the classic case) that isn't actually supported by the HTTP protocol, for security reasons. There are all sorts of things involving redirects that could be used for Phishing-type attacks on users, if they were implemented within the hypertext protocol.
As was revealed in a recent thread on the PHP lists, redirection is one of the commonest ways in which all the major browsers (yes, Mozilla, too) fail to adhere properly to the standards. See:
ppewww.ph.gla.ac.uk/~flavell/www/post-redirect.html
(Sweet mother of Jesus - third edit! I'd like to see what genius came up with the script for munging URLs on this forum!
Don't just click on the link above, because the ASP scripts this site uses will leave the 'ppe' portion of the hostname off, in the above URL, and I can't work out how to stop it doing so. To summarise: the first portion of the URL above should read 'ppewww', not 'www', as the script seems to think, so just cut&paste the whole URL into a new browser address bar.)
The error is caused by the way you set the onload handler. I don't think you can set a method name and pass in a variable as well. You'll have to create a new function that calls your code, like this:
Code:
onload = new Function ("setChecked('opt3308');");
Alternatively, and much easier, set the onload attribute of the <body> tag:
Code:
<body onload="setChecked('opt3308');">
Hope this helps,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Getaway Car by Audioslave (Track 13 from the album: Audioslave) What's This?
Ok...it is as clear as mud to me...I tried it like Chris suggested, I do not get the error, but the script does not work. Plus I do not understand why having function() and putting the actual function inside of {} helps? If someone can expound, I would appreciate it.
Imar, I tried your way with putting it in the body...did not work because I already have an onload in the body tag. As for your other suggestion, you have a function calling a function? how does that help and just how do you do that? I have never done that and do not know the syntax, especially for carrying through values.
I tested the page before I posted it, and it worked fine, so maybe something else is going wrong. Anyway, I don't have a function calling another function, but to the onload event, I assign a new function created on-the-fly. By assigning new Function(bla bla bla) to the onload event, the code bla bla bla is executed.
The onload attribute of the body tags allows multiple function calls. Just separate them with a semi colon:
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
While typing this post, I was listening to: Dirty boots by Sonic Youth (Track 5 from the album: Dirty boots) What's This?
If you already have an onload attribute in your body tag, you can add more function calls to this e.g.
<body onload="function1(); function2();">
onload = function(){setChecked('opt3308')}; and onload = new Function ("setChecked('opt3308');"); do the same thing - they create a new function to be executed (but do not call it) when the onload event fires, you need to do this because simply coding onload = setChecked('opt3308'); causes the code on the right of the "=" sign to be evaluated & assigned to the item on the left, in this case onload. If your function had no parameters, you could simply use onload = setChecked;
The reason the code I posted is not working is that by setting a value for the onload attribute in the body tag, you are overriding the onload function specified by onload = function(){setChecked('opt3308')};
Ok, the reason the onload in the body tag won't work is because the select menu is not rendered yet. So it is firing upon something that does not exist. SO that did not work. I tried the following code per Imar and it did not work...thoughts?...
function setChecked0(selvalue)
{
if(ID[0][2] == 'Y')
{
document.getElementById(selvalue).selectedIndex = 0;
}
else
{
document.getElementById(selvalue).selectedIndex = 1;
}
}
//onload = setChecked0('opt3308');
onload = new Function ("setChecked('opt3308');");
By the way, when I uncomment my original code, the code itself works but I get the not implemented error.