Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-05-2005, 03:56 PM   PM User | #1
adrienne
New to the CF scene

 
Join Date: Jul 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
adrienne is an unknown quantity at this point
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.
adrienne is offline   Reply With Quote
Old 07-05-2005, 04:21 PM   PM User | #2
martin_narg
Regular Coder

 
martin_narg's Avatar
 
Join Date: Jul 2002
Location: Chamonix, France
Posts: 600
Thanks: 1
Thanked 3 Times in 3 Posts
martin_narg is an unknown quantity at this point
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
__________________
"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

Last edited by martin_narg; 07-05-2005 at 05:08 PM..
martin_narg is offline   Reply With Quote
Old 07-05-2005, 05:06 PM   PM User | #3
adrienne
New to the CF scene

 
Join Date: Jul 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
adrienne is an unknown quantity at this point
Smile

Ah that looks good - tomorrow I will test and see if it works - what a speedy answer! Thanks dude
adrienne is offline   Reply With Quote
Old 07-06-2005, 08:35 AM   PM User | #4
adrienne
New to the CF scene

 
Join Date: Jul 2005
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
adrienne is an unknown quantity at this point
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
adrienne is offline   Reply With Quote
Old 07-06-2005, 09:14 AM   PM User | #5
martin_narg
Regular Coder

 
martin_narg's Avatar
 
Join Date: Jul 2002
Location: Chamonix, France
Posts: 600
Thanks: 1
Thanked 3 Times in 3 Posts
martin_narg is an unknown quantity at this point
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
martin_narg is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 08:21 PM.


Advertisement
Log in to turn off these ads.