国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

簡單了解JS打開url的方法

2024-05-06 15:44:44
字體:
供稿:網(wǎng)友

這篇文章主要介紹了簡單了解JS打開url的方法,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下

在新標簽頁中g(shù)et方式打開url

window.open(loginurl_withaccout, "_blank");

下面根據(jù)后臺返回的url以及用戶名密碼字段,以及用戶名密碼動態(tài)生成了帶賬號的url。

$.ax('./front/getURLBySidAndUid', {sysid:sysid}, 'POST', function(d) {  var loginurl_withaccout = d.loginurl + "?"+d.namefield+"="+d.username+"&"+d.pwdfield+"="+d.userpwd;  console.info(loginurl_withaccout);  window.open(loginurl_withaccout, "_blank");}, function(e) {  layer.alert('出問題啦~請稍后再試~',{title:'提示',icon: 2});}, false); //同步

在新標簽頁中post方式打開url

下面這種方式支持IE9以上以及谷歌火狐.但是不支持360

/*獲取系統(tǒng)帶參數(shù)的登錄url*/$.ax('./front/getURLBySidAndUid', {sysid:sysid}, 'POST', function(d) {  /*get跳轉(zhuǎn)*/  /*var loginurl_withaccout = d.loginurl + "?"+d.namefield+"="+d.username+"&"+d.pwdfield+"="+d.userpwd;  window.open(loginurl_withaccout, "_blank");*/  /*post跳轉(zhuǎn)*/  var params = new Array();  params.push({ name:d.namefield,value:d.username},{name:d.pwdfield,value:d.userpwd});  openPostWindow(d.loginurl,params,"_blank");}, function(e) {  layer.alert('出問題啦~請稍后再試~',{title:'提示',icon: 2});}, false); //同步  /**   * 動態(tài)創(chuàng)建form表單 - 實現(xiàn)post帶參數(shù)跳轉(zhuǎn)到新tab頁   **/  function openPostWindow(url,params,name){    var tempForm = document.createElement("form");    tempForm.id="tempForm_post";    tempForm.method="post";    tempForm.enctype="application/x-www-form-urlencoded";    tempForm.action=url;    tempForm.target=name; /*打開新窗口*/    tempForm.style.display = "none";    //添加參數(shù)    for (var item in params) {      var input = document.createElement("input");      input.name = params[item].name;      input.value = params[item].value;      tempForm.appendChild(input);    }    document.body.appendChild(tempForm);    tempForm.submit();    document.body.removeChild(tempForm);  }

window.location和window.open區(qū)別

性質(zhì)不同

window.location:window.location是window對象的屬性。 window.open:window.open是window對象的方法。

用途不同

window.location:window.location用來替換當前頁,也就是重新定位當前頁 。 window.open:window.open用來讓鏈接頁面在窗口中打開。

打開網(wǎng)站不同

window.location:window.location只能在一個網(wǎng)站中打開本網(wǎng)站的網(wǎng)頁。 window.open:window.open可以在一個網(wǎng)站上打開另外的一個網(wǎng)站的地址 。

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持錯新站長站。

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 临海市| 新民市| 牟定县| 苍山县| 博白县| 涿鹿县| 汶上县| 精河县| 万安县| 大渡口区| 海伦市| 鄂州市| 忻城县| 古浪县| 桦甸市| 伊通| 广安市| 玉环县| 靖西县| 思南县| 嫩江县| 曲松县| 瓦房店市| 西和县| 绥滨县| 和平县| 怀柔区| 赣榆县| 云南省| 临猗县| 河津市| 长乐市| 彩票| 五台县| 比如县| 简阳市| 英吉沙县| 平泉县| 彰化县| 虎林市| 时尚|