0

I have this neat little code:

<script type="text/javascript" language="javascript">
$(function(){
 $(window).hashchange( function(){
   window.scrollTo(0,0);
   var hash = location.hash;
   if (hash == "") {
   hash="#main";
   }
     var newhash = !/\.php$/i.test(hash)? hash+".html": hash;
     ajax_loadContent('m',newhash.slice(1,newhash.length));
  $('.menu li a').each(function(){
     var that = $(this);
     that[ that.attr( 'href' ) === hash ? 'addClass' : 'removeClass' ]( 'current' );
  });
 })
 $(window).hashchange();
});

</script>

The only problem is that if I navigate to pages containing Javascript that code isn't being executed. How can I make it run the Javascript code as if the browser loaded the page normally?

user1841964
  • 101
  • 1
  • 2
  • 8
  • Does it help? http://stackoverflow.com/questions/10888326/executing-javascript-script-after-ajax-loaded-a-page-doesnt-work – Nashi Dec 14 '12 at 12:36
  • Currently I use parseScript found in that thread but all my functions from `` aren't loaded – user1841964 Dec 14 '12 at 16:04

1 Answers1

0

It will not be execute as it comes as text. You have to use "eval" function on your response text

user160820
  • 14,866
  • 22
  • 67
  • 94