vefminnesota.blogg.se

Javascript content switcher
Javascript content switcher












javascript content switcher
  1. #Javascript content switcher how to#
  2. #Javascript content switcher free#

This involves looping through every link element in the document, disablingĪll preferred and alternate style sheets that we don’t want active, and enabling all preferred and alternate style sheets that we do want active. Using these three checks we can write a function to switch style sheets. Note that we check for the string “alt” because some browsers accept the keyword “alternative” in place of “alternate.” HTMLLinkElement.getAttribute("rel").indexOf("alt") != -1 HTMLLinkElement.getAttribute("rel").indexOf("style") != -1ĭoes the rel attribute contain the keyword “alternate”? Need to check two of the attributes of each link element. You have to wait until the elements are loaded. This means that some of the HTML elements in the page don't exist yet, and you can't access them in JavaScript. It can however happen, that the rest of the document is not loaded yet.

This is relatively easy to do, as we only When the browser parses your HTML and reaches a
0 kommentar(er)