Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Href anchor problem with Firefox re popups

    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.

  • #2
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    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 ;-)
    Code:
    <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
    Last edited by martin_narg; 07-05-2005 at 05:08 PM.
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper

  • #3
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Smile

    Ah that looks good - tomorrow I will test and see if it works - what a speedy answer! Thanks dude

  • #4
    New to the CF scene
    Join Date
    Jul 2005
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    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

  • #5
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    Try this, it should resolve any capitalization issues, it also supports users without javascript enabled:

    Code:
    <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
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •