国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

js關(guān)閉當(dāng)前窗口報(bào)錯(cuò)Scripts may close only the windows that were opened by them

這篇具有很好參考價(jià)值的文章主要介紹了js關(guān)閉當(dāng)前窗口報(bào)錯(cuò)Scripts may close only the windows that were opened by them。希望對(duì)大家有所幫助。如果存在錯(cuò)誤或未考慮完全的地方,請(qǐng)大家不吝賜教,您也可以點(diǎn)擊"舉報(bào)違法"按鈕提交疑問。

一、問題

js關(guān)閉當(dāng)前窗口報(bào)錯(cuò)Scripts may close only the windows that were opened by them,JS,# 瀏覽器,javascript,前端,window.close

Chrome瀏覽器中調(diào)用window.close()關(guān)閉當(dāng)前頁面時(shí)瀏覽器控制臺(tái)報(bào)出 Scripts may close only the windows that were opened by them. 且無法關(guān)閉當(dāng)前頁面。

先上結(jié)論:不是通過JS打開的瀏覽器標(biāo)簽,都不能通過window.close()來關(guān)閉當(dāng)前頁面

二、原因

MDN對(duì)于window.close()的解釋如下所示:

js關(guān)閉當(dāng)前窗口報(bào)錯(cuò)Scripts may close only the windows that were opened by them,JS,# 瀏覽器,javascript,前端,window.close

文章里說,close只能關(guān)閉用在JS腳本里用open方法打開的窗口。因此下面的代碼有效。

var win = window.open("https://www.oschina.net");
win.close();

或者說在窗口A執(zhí)行代碼

window.open("http://example.com")

然后在新創(chuàng)建的example.com窗口執(zhí)行下面的代碼也可以關(guān)閉。

window.close()

三、解決

在當(dāng)前頁面自身通過 window.open()方法打開一個(gè)空白頁面
調(diào)用 window.close()關(guān)閉

window.open("about:blank", "_self")
window.close();

四、最后

本人每篇文章都是一字一句碼出來,希望對(duì)大家有所幫助,多提提意見。順手來個(gè)三連擊,點(diǎn)贊??收藏??關(guān)注?,一起加油?文章來源地址http://www.zghlxwxcb.cn/news/detail-806804.html

到了這里,關(guān)于js關(guān)閉當(dāng)前窗口報(bào)錯(cuò)Scripts may close only the windows that were opened by them的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點(diǎn)僅代表作者本人,不代表本站立場(chǎng)。本站僅提供信息存儲(chǔ)空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請(qǐng)注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實(shí)不符,請(qǐng)點(diǎn)擊違法舉報(bào)進(jìn)行投訴反饋,一經(jīng)查實(shí),立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費(fèi)用

相關(guān)文章

  • Mac系統(tǒng)brew報(bào)錯(cuò)“The GitHub credentials in the macOS keychain may be invalid”解決

    Mac系統(tǒng)brew報(bào)錯(cuò)“The GitHub credentials in the macOS keychain may be invalid”解決

    報(bào)錯(cuò)信息如下: $ brew search nginx Warning: Error searching on GitHub: GitHub API Error: Requires authentication The GitHub credentials in the macOS keychain may be invalid. Clear them with: ? printf \\\"protocol=httpsnhost=github.comn\\\" | git credential-osxkeychain erase Create a GitHub personal access token: https://github.com/settings/tokens/new?sco

    2024年02月10日
    瀏覽(28)
  • Mac OS下 使用 osascript 指令,執(zhí)行完可執(zhí)行程序后,關(guān)閉當(dāng)前已結(jié)束的終端(Terminal)窗口)

    Mac OS下 使用 osascript 指令,執(zhí)行完可執(zhí)行程序后,關(guān)閉當(dāng)前已結(jié)束的終端(Terminal)窗口)

    提示:文章寫完后,目錄可以自動(dòng)生成,如何生成可參考右邊的幫助文檔 最近在工作中需要使用shell 腳本的可執(zhí)行程序,在shell里調(diào)用完成一些其他功能。Mac os下 執(zhí)行的時(shí)候是調(diào)用終端(Terminal)。執(zhí)行完成后會(huì)有一個(gè)已結(jié)束終端進(jìn)程界面,一直在桌面顯示,每次都需要手動(dòng)

    2024年02月11日
    瀏覽(27)
  • 解決Docker報(bào)錯(cuò):This error may indicate that the docker daemon is not running.

    解決Docker報(bào)錯(cuò):This error may indicate that the docker daemon is not running.

    ? ? ? ?成功安裝完docker【安裝過程見上一篇Windows安裝docker_up_xin的博客-CSDN博客】后的第二天就遇到了問題,進(jìn)入PowerShell后報(bào)錯(cuò)如下: ? ? ? 網(wǎng)上常見的解決方法是在Service Windows GUI重啟docker desktop service,或者使用?DockerCli.exe -SwitchDaemon命令,但是都沒能解決 ????????網(wǎng)

    2024年02月11日
    瀏覽(20)
  • 【Unity報(bào)錯(cuò)】Some objects were not cleaned up when closing the scene.

    【Unity報(bào)錯(cuò)】Some objects were not cleaned up when closing the scene.

    Unity結(jié)束運(yùn)行的時(shí)候報(bào)錯(cuò)Some objects were not cleaned up when closing the scene. (Did you spawn new GameObjects from OnDestroy?) 結(jié)束運(yùn)行的時(shí)候突然報(bào)錯(cuò),有概率,有時(shí)候有有時(shí)候沒有 結(jié)束運(yùn)行的時(shí)候在OnDestroy中調(diào)用了Mono的單例類,但是呢OnDestroy調(diào)用次序是不同的,有可能A先B后,也有可能是B先

    2024年02月02日
    瀏覽(29)
  • ISE下載程序報(bào)錯(cuò)A problem may exist in the hardware configuration--解決方法(親身踩雷)

    在用ISE下載程序的時(shí)候一直報(bào)錯(cuò):iMPACT:Can not find cable, check cable setup iMPACT:A problem may exist in the hardware configuration. Check that the cable, scan chain, and power connections are intact, that the specified scan chain configuration matches the actual hardware, and that the power supply is adequate and delivering the correct vo

    2024年02月09日
    瀏覽(117)
  • 報(bào)錯(cuò):The Tomcat connector configured to listen on port xxxx failed to start. The port may already be

    報(bào)錯(cuò):The Tomcat connector configured to listen on port xxxx failed to start. The port may already be

    APPLICATION FAILED TO START Description: The Tomcat connector configured to listen on port xxxx failed to start. The port may already be in use or the connector may be misconfigured. Action: Verify the connector’s configuration, identify and stop any process that’s listening on port xxxx, or configure this application to listen on another port. 原因:

    2024年02月12日
    瀏覽(38)
  • 項(xiàng)目依賴安裝node-sass@^4.14.1 run “node scripts/install.js“報(bào)錯(cuò)問題解決

    項(xiàng)目依賴安裝node-sass@^4.14.1 run “node scripts/install.js“報(bào)錯(cuò)問題解決

    很久沒運(yùn)行的項(xiàng)目突然依賴下載報(bào)錯(cuò),讓我很頭疼,之前都是運(yùn)行正常的,于是就是開找解決辦法。 依賴下載遇到的報(bào)錯(cuò)!??! scripts.install node-sass@^4.14.1 run “node scripts/install.js”: 大概意思就是這個(gè)地址已經(jīng)不能下載了,需要你下載到本地并且做一個(gè)代理: 第一步: nod

    2024年02月20日
    瀏覽(27)
  • The Node.js path can contain only letters,digits,periods (.),underscores...

    The Node.js path can contain only letters,digits,periods(.),underscores(_),?hyphens (-), colon (:) and backslash(); 解決辦法: DevEco Studio設(shè)置Nodejs提示路徑只能包含英文、數(shù)字、下劃線等-CSDN博客 補(bǔ)充: 文件路徑:C:Users***AppDataRoamingHuaweiDevEcoStudio3.1optionsother.xml 也可以在DevEco Studio中,選擇路徑

    2024年02月04日
    瀏覽(24)
  • js(javascript)中頁面跳轉(zhuǎn)和窗口關(guān)閉等操作

    1、self.loaction.href=\\\"/具體路徑\\\" 2、location.href=\\\"/具體路徑\\\" 3、windows.loaction.href=\\\"/具體路徑\\\" 4、this.loaction.href=\\\"/具體路徑\\\" parent.location.href=\\\"/具體路徑\\\" top.location.href=\\\"/具體頁面\\\" window.location.reload() 使用該方法刷新頁面時(shí),如果有數(shù)據(jù)待提交,會(huì)提示是否提交 如果頁面中自定義了f

    2024年02月16日
    瀏覽(19)
  • 成功解決Pycharm報(bào)錯(cuò):Note: you may need to restart the kernel to use updated packages.

    成功解決Pycharm報(bào)錯(cuò):Note: you may need to restart the kernel to use updated packages.

    pycharm中 import sklearn 報(bào)錯(cuò): 然后在pycharm的控制臺(tái)console中使用 pip install sklearn 安裝了sklearn包,使用 pip list 命令查看安裝成功: 但是,最 玄學(xué) 的事情來了,明明安裝成功,import卻還是和剛開始一樣的報(bào)錯(cuò)。 細(xì)看發(fā)現(xiàn) pip list 的末尾有一句: 我知道jupyter怎么重啟內(nèi)核,但是p

    2024年02月04日
    瀏覽(63)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請(qǐng)作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包