Gérard Talbot said:
Csaba Gabor wrote :
This will trigger a validation error. Also, there is no need for
"javascript:" pseudo-protocol. Unless you're creating a bookmarklet, the
recourse to "javascript:" pseudo-protocol is always wrong, incorrect.
http://jibbering.com/faq/#FAQ4_24
http://developer.mozilla.org/en/doc...D.22javascript:window.open.28....29.22_....3E
Well, those two pages have NOTHING to do with the situation here.
Those pages say don't put href="javascript:..." within a link. This
situation has nothing to do with a link.
The fact that we're using window.open at all guarantees that javascript
is running, and the reason for using the javascript: is to return html
that is to be used as page content (as opposed to having a string url
which causes the browser to run out to the internet. That can mean a
potentially huge delay, which is what started this whole thread off)
Validation error here too: unescaped /
???
I don't understand the purpose, reasons, justifications of setTimeout at
each of the 3 spots called in this code.
OK, this is a good point. I shouldn't have them there for the purposes
of this discussion (and I should only have one button). But here's why
they were there: If you put the alert back into the code, then the
button appears as you would expect. However, on my system (where I
embedded the whole page within a frame) using FF, I would get an
intermittent error (I can't consistently reproduce it else I'd have
already reported it to
http://bugzilla.mozilla.org ) where after one
button press, the button would no longer fire if it tried to execute
the window.open. I tried putting in window.setTimeouts just in case
(that why the first two were there), but that didn't work. The fix
that actually worked was to reset the handler to its original function
(which is why the third one was there - it's just a copy of the first
button's event handler). Thus, the second button still failed from
time to time.
Here's the code again, without the distracting setTimeout
Csaba Gabor
<button id=btn1 accesskey=c onclick="dlgShow()">
<u>C</u>lick me</button>
<script type='text/javascript'>
function dlgShow() {
var nw=window.open("javascript:'<html><head><title>" +
"Test</title><head><body>should be a button here </body>'");
alert("Alert needed for FF"); // should not be needed
var btn = nw.document.createElement("button");
btn.innerHTML = "Dialog <u>b</u>utton"
btn.accessKey = "b";
btn.onclick = function() {nw.alert("Dlg button clicked");}
nw.document.body.appendChild(btn);
}
</script>