Is there a way to change the attributes of the <html> tag at runtime?

I want to add a manifest attribute at runtime, so I can control when Appcache will load.

Example: if the user is correctly registered in the application,

<html>
// page content
</html>

changes to:

<html manifest="myapp.manifest">
// page content
</html>

Anyway, can I achieve this using javascript, jquery or anything else? I want to control when Appcache will be loaded conditionally. (I already read that there is another html in iFrame.)

+4
source share
6 answers

According to the specification, changing an attribute manifestafter loading a document has no effect.

html document.documentElement:

document.documentElement.setAttribute('manifest', 'myapp.manifest');

.

+9

. attr():

.

$('html').attr('manifest','myapp.manifest');
+3

,

document.documentElement.setAttribute('manifest', 'foo.appcache');

( @FelixKing , document.documentElement.manifest , manifest DOM. Chromes .)

. HTML5 CR :" . , (, , DOM API).

(, , , .. , .)

+2

:

document.documentElement.setAttribute('manifest', 'myapp.manifest');

docs:

document.documentElement

, ( , HTML-).

+1

jQuery.

$('html').attr('manifest', 'myapp.manifest');
0

, , , .

appcache, :

window.console.warn('removing appcache');
window.document.documentElement.removeAttribute('manifest');

, !

0

Source: https://habr.com/ru/post/1533657/


All Articles