Solved

Javascript window.location.hash IE problems

Posted on 2008-06-25
3
7,442 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
  • 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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

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…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will demonstrate how to add subdomains to your content reports. This can be very importing in having a site with multiple subdomains.
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.

762 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now