Window.open url rewrites the base url two times [closed]

旧城冷巷雨未停 提交于 2020-06-09 07:10:20

问题


Uder my Angular app ; i m formating an url to open it in a new window :

example :

myURL = `http://www.mywebsite.fr/BB/196?VARIABLEONE=2632&VARIABLETWO=FFHJK&VARIABLETHREE=TEST/`

when using it :

window.open(myURL) ; it doesn't open me that yurl , but i's opening this one :

https://www.mywebsite.fr/?http://www.mywebsite.fr/BB/196?VARIABLEONE=2632&VARIABLETWO=FFHJK&VARIABLETHREE=TEST

as you can see it inject the base url (www.mywebsite.fr) one extra time in the beginiing ,

i want to evitate this

Suggestions ?


回答1:


try this

 const myURL = `http://www.mywebsite.fr/BB/196?VARIABLEONE=2632&VARIABLETWO=FFHJK&VARIABLETHREE=TEST/`

 window.open(myURL, "_blank");

Syntax for Window.Open

window.open(url, windowName, [windowFeatures]);

Where

  • url - URL of the resource to be loaded

  • windowName|target -A DOMString specifying the name of the browsing context (window, or tab) into which to load the specified resource

  • windowFeatures - A DOMString containing a comma-separated list of window features given with their corresponding values in the form "name=value3




回答2:


Try with the following:

myURL = 'http://www.example.com';

$window.open(myURL, '_blank');


来源:https://stackoverflow.com/questions/62213583/window-open-url-rewrites-the-base-url-two-times

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!