问题
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