[nycphp-talk] Need some JS / HTML help
David Krings
ramons at gmx.net
Sat Dec 22 21:06:15 EST 2007
Hi!
Thanks Nestor, your examples helped at least to point me to the right
direction although you didn't copy the popup code, but the stuff that is in
the popup window. But I found the source page and could figure it out,
although their approach didn't work for me, but see below.
Néstor wrote:
> Here is an ezample on how to do it with a popup but I think that you can
> also do it
> if you put a link and set the target to blank "target=blank"
>
OK, I got the target in the regular hyperlink all set and that works at least
for those cases where JavaScript isn't an option. I still can't get anything
from JavaScript. What I did see in the Defintive Guide that one can write the
JS code into the fref attribute. That causes the browser to render the link,
which it didn't do before, and it opens the desired window, but it also
navigates away from the source page and in Firefox at least shows a blank page
with the text [object window]. It is halfways there, but as bad as before somehow.
But while I was writing this I got another idea that led to another idea and
some more googling and now I got it. I don't really know why it works, but it
does work:
<a href=""
onClick="javascript:window.open('http://localhost:8080/file:/F:/piviviewer/include/help/en_us/Default_CSH.htm#100',
'HelpWindow',
'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,width=350,height=250');">?</a>
What I'm surprised about is that in order to get a link rendered the href
attribute needs to be present, but when no URL is specified the click on the
link doesn't do anything, but the onClick event fires and executes the code.
But then I tried a subsequent link / button and as it turns out the popup is
behind the main window. So I needed to find a way to give it focus and after
some more googling I got this:
<button onClick="javascript:var
w=window.open('http://localhost:8080/file:/F:/piviviewer/include/help/en_us/Default_CSH.htm#100',
'HelpWindow',
'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,copyhistory=no,resizable=yes,width=800,height=550');
w.focus(); return false;">Help Me</button><noscript><a
href="http://localhost:8080/file:/F:/piviviewer/include/help/en_us/Default_CSH.htm#100"
target="HelpWindow">Help Me</a></noscript>
And I got the CSH portion also down and with my little function I can
customize the button caption or only show a ? or have a text link with custom
text. I then tried the code without JavaScript enabled to see if the
<noscript> portion works, but that doesn't do a thing. If anyone knows how to
add the proper noscript code, let me know.
David
More information about the talk
mailing list