开发者

IE Problem: Won't execute javascript loaded as part of AJAX content

I'm loading AJAX content that contains a javascript function inside the AJAX content. I'm using the jQuery .load function and calling done() on completion.

$('#content').load(a, done);

function done()
{
    if(pagejs() == 'function')
    {
        pagejs();
    }
}

I'm not able to get the function to execute in IE 9 but in FF and Chrome the script is executed fine. In IE, I'm getting a SCRIPT5007: Object expected error on the if(pagejs() == 'function') line.

I added the compatibility meta tag: <meta http-equiv="X-UA-Compatible" content="IE=8" /> still with no success.

Here is a sample of the AJAX content:

<div id="about"><h1>About This Website</h1>

<script type="text/javascript">
function pagejs(){alert('content was loaded from dynamic script');}
</script>

<p>This is test AJAX content</p>

In IE, the pagejs(); is undefined. Can someone please tell me how I can get IE to recognize开发者_Python百科 this script? Thank you.


pagejs() == 'function'

That executes pagejs and compares it's return value to the string function.

You want typeof pagejs === 'function'


Try if(typeof(pagejs) == 'function')

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜