JavaScript Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsWeb DesignJavaScript Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 24th, 2012, 03:24 PM
otnj2ee otnj2ee is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2005
Posts: 46 otnj2ee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 41 m 8 sec
Reputation Power: 8
Reload javascript on IE9

Using IE9.

In the JSP page, I added <script type="text/javascript" src="test/scripts/test.js" ></script>

The file test.js contains a simple function test(){alert("loaded");} to open the alert window.

Next I created a button named Launch to call this function. When clicked the button, just as expected, the popup window opened and displayed the word: loaded. So far so good.

Then I went to the browser's URL address box on top and launched a new page, such as www.google.com. Once this page is loaded, I clicked the browser's BACK button to came back to my original page.

Once my page was loaded, I clicked the Launch button. This time, the function test(){alert("loaded");} never got executed.

When so?


(It seems that when the BACK button brought back the original page, the <script type="text/javascript" src="test/scripts/test.js" ></script> is either not execute or the test/scripts/test.js is not loaded. However the same codes worked well on Firefox).

Reply With Quote
  #2  
Old October 24th, 2012, 07:44 PM
web_loone08's Avatar
web_loone08 web_loone08 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2008
Posts: 605 web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 16 h 34 m 55 sec
Reputation Power: 69
Try this...

Code:
JavaScript
<script>
function test()
{
alert("loaded");
}
document.onreadystatechange = function() {
if (document.readyState=="complete") {
 new test();
}
}
</script>

Reply With Quote
  #3  
Old October 24th, 2012, 08:38 PM
otnj2ee otnj2ee is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Nov 2005
Posts: 46 otnj2ee User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 10 h 41 m 8 sec
Reputation Power: 8
The problem is that the sample code I gave is quite simple. In reality, the javascripts are put in multiple .js files which are in turn loaded by a group of <script type="text/javascript" src="xxxxxxxx/yyy.js" ></script>. After came back to the previous page via the browser's BACK button, for some reason, the .js files are either not loaded or not interpreted by the browser. As the result, when clicked the same button as before, the same functions contained in the file גןdid not get executed.

Last edited by otnj2ee : October 24th, 2012 at 08:41 PM.

Reply With Quote
  #4  
Old October 24th, 2012, 09:00 PM
web_loone08's Avatar
web_loone08 web_loone08 is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2008
Posts: 605 web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level)web_loone08 User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Week 1 Day 16 h 34 m 55 sec
Reputation Power: 69
Oh... sorry, missed the button; was thinking you needed a document event trigger. If your function has been assigned to the button (either dynamically or inline); the button's DOM event (ie "onclick") still should trigger the function; whether you remain on the page or leave the page and then, come back to the page. If the button has been assigned an DOM event; it should retain, that event. Unless your button's DOM event is re-assigned somewhere in your other JavaScript files.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignJavaScript Development > Reload javascript on IE9

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap