javascript - jquery .each() function taking effect on browser "go back" button only -


i have webpage i'm loading div page using .load(). after loading run jquery code append specific url existing hrefs. issue first time click on hyperlink/href redirected old href. after click "go back" button on browser, , try same hyperlink/href, href works , takes me new appended href.

i see if there anyway have hrefs change when first load page.

here code:

1st initialize container loading container second page.

<pre>   <code id="iframe-fragment"></code> </pre> 

2nd load second page's container current webpage.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> <link href="https://roboticsys.com/support/plugins/servlet/docs/c1001-d1003/rapidcode/rsi_stylesheet.css" rel="stylesheet" type="text/css"> <script>   $('#iframe-fragment').load('https://roboticsys.com/support/plugins/servlet/docs/c1001-d1003/rapidcode/_absolute_motion_8cs-example.html div.fragment');  </script> 

3rd append url hrefs in imported container.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js"></script> <script>   $(document).ready(function() {     $("a").each(function() {       var $this = $(this);              var _href = $this.attr("href");        $this.attr("href", 'https://appended-url.com/' + _href);     });   }); </script> 

thank in advance.

seems load() content being browser cached , apparent content on page once hit button.

however before this, on initial page load, document complete, , runs each, load isn't complete. in scenario content wouldn't updated.

i'd rather update urls via load complete callback:

$('#div').load('http://myurl', function(res, status, xhr){     //you can use parameters sort of conditionals     $('a').each(function(){       //your code edit urls     }); }); 

Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -