0

此代码在 IE 中不起作用,为什么不呢?

$('body').append('<div id="iedialog"><h2 class="dialog-header">Alert!</h2><div class="dialog-container"><center>It looks like you are using Internet Explorer! Please switch to another browser to use all our Designer features. We recommend Firefox (<a href="www.firefox.com">www.firefox.com</a>) and Google Chrome (<a href="www.google.com/chrome">www.google.com/chrome</a>) for an overall better internet experience.<br /><br /><input type="button" value="OK" id="okiedialog"></center>');

然而,如果我将这个确切的代码复制并粘贴到控制台中,它就可以工作。

4

1 回答 1

1

我会指出您的代码存在的几个问题。附加的标记无效。分解时可见。

1)您的代码未正确关闭

<div id="iedialog">
    <h2 class="dialog-header">Alert!</h2>
    <div class="dialog-container">
        <center>
            It looks like you are using Internet Explorer! Please switch to another browser to use all our Designer features. We recommend Firefox (<a href="www.firefox.com">www.firefox.com</a>) and Google Chrome 
            (
                <a href="www.google.com/chrome">www.google.com/chrome</a>
            ) 
            for an overall better internet experience.
            <br />
            <br />
            <input type="button" value="OK" id="okiedialog">
        </center>

您的input标签未关闭,您div的带有 classdialog-container和 id的 siedialog未关闭。

1)您的标记使用不推荐使用的 tag center。摆脱它,然后再试一次。

于 2013-05-04T16:55:39.953 回答