www.webdeveloper.com
Results 1 to 10 of 10

Thread: [RESOLVED] Firefox Won't go to the targeted ID

  1. #1
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,105

    resolved [RESOLVED] Firefox Won't go to the targeted ID

    Hello,

    I'm running into an issue with Firefox and Opera in that it won't go to the targeted portion of the page by using the ID.

    Here's an example:

    http://dell.msn.com/#foot

    If you go there, you should be dropped down into the footer because the element has the id "foot". In Firefox and Opera, it doesn't take you down to the bottom unless you put your cursor back in the address bar and click return again. I need the ability to direct users to a section of the page based on this.

    Any ideas? It works in IE, Safari, Chrome.

    Thanks.

  2. #2
    Join Date
    Dec 2005
    Posts
    2,984
    Also works in FF3.6.3 and Opera 10.51
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...
    awesome.

  3. #3
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,105
    Very weird. I'm using FF 3.6.3, and when I paste the url "http://dell.msn.com/#foot" into a new window, it doesn't take me to the footer.

  4. #4
    Join Date
    Dec 2005
    Posts
    2,984
    Clear your cache.....that's all I got.
    I've switched careers...
    I'm NO LONGER a scientist,
    but now a web developer...
    awesome.

  5. #5
    Join Date
    Apr 2010
    Posts
    213
    It's a scripted behavior from s-msn.com. If you browse it in Firefox with no-script and block s-msn.com, it will work properly.

    Interesting...

    Cheers,

    Chipzzz

  6. #6
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,105
    Hm, it does indeed work with JavaScript turned off. The funny thing is that what made me investigate this is that it's happening in a project i'm working on (so it's not only MSN).

    There is a lot of AJAX going on in my project, so I'm guessing it's somehow related. This one is going to be tricky!

    It's definitely something with the script. Thanks for your help fellas.

  7. #7
    Join Date
    Mar 2010
    Posts
    10
    Clear cookies & have a go at it. FF keeps updating and little problems seem to come with it.

  8. #8
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,105
    I've narrowed the issue down and found that this is the piece of the script that causes the targeting to fail:

    Code:
    $("#main .scroll-wrap").css('height', '200px');
    I'm basically resizing the content area based on the users window size (in the example above I've simply put '200px'). The targeted #whatever is inside the scroll-wrap div, so when it resizes, FF must put the user back to the top of the document instead of going down to #whatever.

    I'm thinking I can tweak the script to extract the targeted element from the URL then go to it.

  9. #9
    Join Date
    Sep 2008
    Location
    Akron, OH
    Posts
    1,105
    Just wanted to post the working tweak if anyone cares!

    Code:
    	// firefox wouldn't go to target on load due to resizing, so this function was created
    	function goToTarget(){ 
    		var myLocation = document.location.hash.replace("#","");
    		if (myLocation) {  
    			myLocation = '#' + myLocation;
    			window.open(myLocation,'_self')
    		};
    	};
    	
    	// firefox needs to call this to go to the selected target
    	goToTarget();
    Sorry this has turned into a JavaScript thread!

  10. #10
    Join Date
    Apr 2010
    Posts
    213

    It's OK

    It's OK, JavaScript is interesting too. Thanks for the exercise & the solution .

    Chipzzz

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles