- 1.使用表单
- function btuFun(){
- openBlankWindow('http://www.bing.cn','contactus');
- }
- //open blank window
- function openBlankWindow(sHref,objValue) {
- document.getElementById("msgTxt").innerhtml="<form id='hiddenlink' action='"+sHref+"' target='_blank'>
- <input name="names" value='"+objValue+"' /form>";
- var s=document.getElementById("hiddenlink");
- s.submit();
- }
- <input type="button" value="submit" onclick="btuFun()" />
- 2.使用a标签
- <!-- 做弹出窗口临时用的 -->
- <a target="_blank" id="active" href="" onclick="return true;" style="display: none;"></a>
- funciton active(){
- //触发A标签的href事件
- var active = document.getElementById('active');
- active.href=result;
- active.click();
- }
- <input type="button" value="submit" onclick="active()" />
- 注意的地方:
- 如果是在jquery中ajax中一定需要加async:false,不然就是模式窗口;
- //该片段来自于http://www.codesnippet.cn/detail/250220148777.html
来源: http://www.codesnippet.cn/detail/250220148777.html