简体   繁体   中英

Change <body> ID with Javascript from within ContentPage

I'm looking to do a short term hack on a site. The site is a ASP.NET site with a master page. The body tag is in the master page. I'd like to specify which ID should be in the body tag from within various content pages. What I don't know is if you can have this type of access to the body tag when your JS is within the body tag. For various reasons, I'd like to try to accomplish this in JS, not .NET.

Any tips?

Rephrasing for clarity:

I would like to use JavaScript to specify a body ID from within the body tag of a site. For example:

<body id="MyID">

JS to change MyID to another name

</body>

Put this in the Page_Load of any ContentPage...

string JS = "document.body.id = 'WhateverID';";
ClientScript.RegisterStartupScript(this.GetType(), "BodyID", JS, true);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM