html - How to change the baseURI of a Node in Javascript - Stack Overflow

The MDN doc claims that there are two ways of changing a Node .baseURI attribute:When an HTML <base&

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?

Share Improve this question edited May 23, 2017 at 11:53 CommunityBot 11 silver badge asked Feb 23, 2015 at 17:32 RenaudRenaud 4,6788 gold badges45 silver badges74 bronze badges 3
  • 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
Add a ment  | 

1 Answer 1

Reset to default 4

I believe the .baseURI attribute is read only. Check here: http://help.dottoro./ljhvjgiu.php

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745182866a4615500.html

相关推荐

  • html - How to change the baseURI of a Node in Javascript - Stack Overflow

    The MDN doc claims that there are two ways of changing a Node .baseURI attribute:When an HTML <base&

    5小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信