NYCPHP Meetup

NYPHP.org

[nycphp-talk] Need some JS / HTML help

David Krings ramons at gmx.net
Sun Dec 23 08:48:38 EST 2007


dirn at dirnonline.com wrote:
> Here's an simplified example from a page I set up with a tabbed inferface:
> 
> <a href="/path/to/main/page/tab1" onclick="Browser.ActivateTab ('tab1'); return false;">
> 

Here is my link crafted accordingly
<a 
href="http://localhost:8080/file:/F:/piviviewer/include/help/en_us/Default_CSH.htm#100" 
target="HelpWindow" onClick="var 
w=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=800,height=550'); 
w.focus(); return false;">?</a>

While it works without JavaScript, it ends up to work the same with JavaScript 
enabled...or better to say, the JavaScript code never gets executed even when 
JavaScript is enabled. In your example you load either the tab or the entire 
new page into the same window that is currently in use. I want to have a JS 
popup and when JS is disabled a plain link into a new window )ends up to be a 
new tab in the modern browsers, which is OK). In this constellation the JS 
popup never shows up. I guess that the browser gives href preference over the 
onClick event.

I will see that I add a generic help link into the page header using an href 
only. So when JS is disabled the user has at least a chance to get to the 
help, it just doesn't come with CSH and the extra window. I could find a 
better fix if there is a way to detect if the browser has JS enabled without 
executing any JS. All solutions I've seen so far pass a value, have JS update 
and return it. If you get the same value back then JS is disabled, but that 
strikes as very ugly. I basically provoke a 'crash', catch it, then act upon 
that. It would be much nicer if browsers send over what they can and can't do 
in the response.

Thanks for your help.

David



More information about the talk mailing list