Solved

Javascript window.location.hash IE problems

Posted on 2008-06-25
3
7,536 Views
Last Modified: 2013-12-08
Alright this peice of code

<script type="text/javascript">
      window.location.hash = '#' + document.cookie;
      alert(document.cookie);
</script>

Works perfect with FF but when I run it in IE it almost shows me the alert window.location.hash does not work with my IE7 any reasons why? Any workarounds? And yes alert gives me the value its suppose to so I know the cookie peice is working.

Thanks
0
Comment
Question by:aumudin
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 4

Author Comment

by:aumudin
ID: 21868067
made some progress...

im using jquery / thickbox iframe modal. So the problem is when in IE window.location.hash tries to use it on the parent window.

Im now trying to figure out how to make it do it on the modal window
0
 
LVL 16

Expert Comment

by:Lolly-Ink
ID: 21880192
This example works for me:

<html>
<script type="text/javascript">
   document.cookie = "divBottom";
 
   function test()
   {
      window.location.hash = '#' + document.cookie;
   }
</script>
<body onload="test()">
   <div id="divTop" style="height:1000">Top</div>
   <div id="divBottom">Bottom</div>
</body>
</html>

Open in new window

0
 
LVL 4

Accepted Solution

by:
aumudin earned 0 total points
ID: 21880543
Yup your very correct that works perfectly just not in a modal window. Reason I have come to find out is IE renders to slowly but reads the code fast so the function even on the onload event executes befor it can find the anchors.

We ended up having to make JavaScript wait a few milliseconds and then it worked perfect.
0

Featured Post

Create Professional Looking Email Signatures

Create "Professional HTML Email Signatures" with ease.
7 Day Money Back Guarantee if not 100% Satisfied.
Affordable - Try it out for 7 Days Totally Risk Free.
Installers provided for over 45 Email clients.
Both Windows & MAC Supported.
Highly Recommended!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSL stands for “Secure Sockets Layer” and an SSL certificate is a critical component to keeping your website safe, secured, and compliant. Any ecommerce website must have an SSL certificate to ensure the safe handling of sensitive information like…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
This Micro Tutorial will demonstrate how nuggets on the Web are formatted by using Chrome Developer Tools. These tools would not only view the site's CSS but it can also modify it and save the CSS to use on your own site.
How to create a custom search shortcut to site-search Experts Exchange using Google in the Firefox browser. This eliminates the need to type out site:experts-exchange.com whenever you want to search the site. Launch your Bookmark Menu: Press 'Ctrl +…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question