最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin2浏览0评论

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

发布评论

评论列表(0)

  1. 暂无评论