...

View Full Version : Href anchor problem with Firefox re popups



adrienne
07-05-2005, 03:56 PM
I am having trouble with my popups. They are to show definitions on a web-based help structure (a self-contained web site). In IE they work, but not in Firefox (or at least randomly, which is strange). This is the code at the top of each web page:
<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, windowname)
{
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href, windowname, 'width=400,height=250,scrollbars=no');
return false;
}
//-->
</SCRIPT>

and I have this code for each definition link:

<A HREF="glossary.htm#definition_anchor"
onClick="return popup(this, 'notes')">name_of_link</a>

Firefox seems to ignore the anchor (bookmark) yet correctly interprets opening the popup containing the glossary document. Is there something unsupported that I am using here? I would like it to be multi-browser compatible.
Thanks for your suggestions.

martin_narg
07-05-2005, 04:21 PM
I've changed var href to var url to prevent any conflicts with reserved keywords, and this now works fine for me in both Firefox and IE, as well as popping back in all the relevent curly brackets ;-)


<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, windowname) {
if(!window.focus) {
return true;
}
var url;
if(typeof(mylink) == 'string') {
url = mylink;
}
else {
url = mylink.href;
}
window.open(url, windowname, 'width=400,height=250,scrollbars=no');
return false;
}
//-->
</SCRIPT>

<a href="glossary.htm#definition_anchor"
onClick="return popup(this, 'notes')">name_of_link</a>


hope this helps

m_n

adrienne
07-05-2005, 05:06 PM
Ah that looks good - tomorrow I will test and see if it works - what a speedy answer! Thanks dude

adrienne
07-06-2005, 08:35 AM
I am very ashamed to say that I have come to the conclusion that IE doesn't care about case sensitivity in anchors, but Firefox does :confused:
I tried Martin's solution (which still lets the popups work, thanks man! but didn't solve the anchor problem) So I had a closer look at one or two pages and realised that in the problem popups, I had left a capital letter at the beginning of the anchor names. This seemed to make no difference in IE but changed everthing in Firefox. This seems weird but there ou go.
Long term I will try to choose a different solution, once my web skills are better, because in any case I have to tell my users to turn off popup blockers if they want to use all the features of the help. So it's all a bit painful and quite frankly slightly second-rate but my site is at least an improvement on its first version - who can ask for more! Thanks again

martin_narg
07-06-2005, 09:14 AM
Try this, it should resolve any capitalization issues, it also supports users without javascript enabled:



<SCRIPT TYPE="text/javascript">
<!--
function popup(mylink, windowname) {
if(!window.focus) {
return true;
}
var url;
if(typeof(mylink) == 'string') {
url = mylink.toLowerCase();
}
else {
url = mylink.href.toLowerCase();
}
window.open(url, windowname, 'width=400,height=250,scrollbars=no');
return false;
}
//-->
</SCRIPT>

<a href="glossary.htm#definition_anchor" target="_blank"
onClick="return popup(this, 'notes')">name_of_link</a>


m_n



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum