The MDN doc claims that there are two ways of changing a Node .baseURI
attribute:
- When an HTML
<base>
tag is found in the document; (1) - When this is a new document created dynamically. (2)
They don't provide an explanation as to how it can be done dynamically (2). They also state that you shouldn't add <base>
elements in html documents (1).
How can I change the .baseURI
attribute dynamically in Javacsript?
[EDIT] According to this SO using base
is perfectly legit. Why is MDN advising against it then?
The MDN doc claims that there are two ways of changing a Node .baseURI
attribute:
- When an HTML
<base>
tag is found in the document; (1) - When this is a new document created dynamically. (2)
They don't provide an explanation as to how it can be done dynamically (2). They also state that you shouldn't add <base>
elements in html documents (1).
How can I change the .baseURI
attribute dynamically in Javacsript?
[EDIT] According to this SO using base
is perfectly legit. Why is MDN advising against it then?
-
I think this begs the question: why do you need to?
.baseURI
is read-only for a reason; perhaps there's a better way. What are you using it for? If you need to, wouldn't having a global variable set to your base URL be more appropriate? – Cᴏʀʏ Commented Feb 23, 2015 at 17:37 - @Cory, I'm adding import tags to the DOM head dynamically. Global variables are of no use here, unfortunately. – Renaud Commented Feb 24, 2015 at 9:50
- The edited link to the other SO question is related to XHTML5 – a standard that never came to living as far as I know. It seems totally unrelated to reality. This question remains unanswered. Re: Why is this needed? Open a new window and create dynamic content into it, which will use images and everything just like it would within the parent document. This needs the parent document's baseURI also applied to the new document. – ygoe Commented Jul 2, 2021 at 9:45
1 Answer
Reset to default 4I believe the .baseURI attribute is read only. Check here: http://help.dottoro./ljhvjgiu.php
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745182866a4615500.html
评论列表(0条)