ajax - Why would javascript eval work in chrome, safari, but in firefox only when firebug on? -


thanks this answer able javascript execute when being loaded via extjs ajax call.

however, following code not work same in browsers (on mac):

  • chrome: works, alert pops up
  • safari: works, alert pops up
  • firefox: works, but when firebug enabled, when firebug not enabled, script ignored

how can javascript execute via ajax call in firefox without having firebug installed?

ext.onready(function(){      var menuitemstart = new ext.panel({         id: 'panelstart',         title: 'start',         html: 'this start menu item.',         cls:'menuitem'     });      var menuitemapplication = new ext.panel({         id: 'panelapplication',         title: 'application',         html: 'this application page',         cls:'menuitem'     });      var regionmenu = new ext.panel({         region:'west',         split:true,         width: 210,         layout:'accordion',         layoutconfig:{             animate:true         },         items: [ menuitemstart, menuitemapplication ]     });      var regioncontent = new ext.panel({         id: 'contentarea',         region: 'center',         padding:'10',         autoscroll: true,         html: 'this content'     });      new ext.viewport({         layout: 'border',         items: [ regionmenu, regioncontent ]     });      menuitemstart.header.on('click', function() {         ext.ajax.request({             url: 'content/view_start.php',             success: function(objserverresponse) {                 regioncontent.update(objserverresponse.responsetext);             }         });     });      menuitemapplication.header.on('click', function() {                      ext.ajax.request({             url: 'content/view_application.php',             success: function(objserverresponse) {                 var responsetext = objserverresponse.responsetext;                 console.log(responsetext);                 regioncontent.update(responsetext);                 var scripts, scriptsfinder=/<script[^>]*>([\s\s]+)<\/script>/gi;                 while(scripts=scriptsfinder.exec(responsetext)) {                     eval(scripts[1]);                 }             }         });      }); }); 

the base being loaded:

<script type="text/javascript">     alert('inside application view'); </script> <?php echo 'this application view @ ' . date('y-m-d h:i:s'); ?> 

console.log culprit.

whenever you're logging in javascript, it's idea check if console exists before calling it's functions:

if(window.console) console.log('whatever'); 

that way, execute when console available.


Comments

Popular posts from this blog

asp.net - repeatedly call AddImageUrl(url) to assemble pdf document -

java - Android recognize cell phone with keyboard or not? -

iphone - How would you achieve a LED Scrolling effect? -