在新窗口中打开外部js表单

时间:2011-06-14 09:49:25

标签: javascript forms window external

在新窗口中打开表单有问题,脚本从外部服务中提取。 看看CODE on JSfiddle

问候

1 个答案:

答案 0 :(得分:1)

您可以在表单呈现后向表单添加目标属性;

<html>
<head>
<script type="text/javascript">
function fixform() {
   //ism is created by the opentable.com script
   document.forms["ism"].setAttribute("target", "_blank");
}
</script>
</head>
<body onload="fixform();">
    <div id="book-table">
    <div id="OT_searchWrapperAll">
            <script type="text/JavaScript" src="http://www.opentable.com/ism/?rid=35449"></script>
            <noscript id="OT_noscript">
                <a href="http://www.opentable.com/single.aspx?rid=35449&restref=35449&rtype=ism">Reserve Now on OpenTable.com</a>
            </noscript>
        </div>
    </div>
</body>
</html>

更新尝试删除onload="fixform();"并使用等效的jQuery;

$(document).ready(function() {
   document.forms["ism"].setAttribute("target", "_blank");
});