javascript - Script works fine in any WebKit based browser but doesn't in Firefox -


I have a script (using WordPress) header.php which looks like this:

< pre> window.addEventListener ( "DOMContentLoaded", function (event) {fixedMenu.init ( "Title-container", 0); fixedMenu.init ( "event type-cover", 20); window.addEventListener ( ' Fixed menu.txt ("Event-Type-Cover");}); var session = "& lt ;? php $ _SESSION [' Lang ']? & Gt; ";});

After this script I include a long script with the script scr = "" tag.

window.addEventListener ("DOMContentLoaded", function (event) {Today = document.getElementById ("Today-Events");; = Document.getElementById ("Upcoming events"); past = document.getElementById ("past-events"); Texter = document.getElementById ("Event-Type"); Changesme ();});

This works fine in any webkit browser, the code is launched, but Firefox does not load other event listeners (I do not know how it loads or not, But if I need it, then it is completely full for the script via the source script embedded source = <.

UPDATE / P>

  nowadays Var upachining; var past; var texter; window.addEventListener ("DOMContentLoaded", function (event) { H = document.getElementById ( "Today's events"); upcoming = document.getElementById ( "upcoming events"), past = document.getElementById ( "historic event"); Texter = document.getElementById ( "event-type" ); change message ();}); Window.onscroll = function () {changeMessage ();} function isElementInViewport (el) {var rect = el.getBoundingClientRect (); return (rect.top> gt; = 0 & amp ; Amp; amp; and; rect.left> = 0 & amp; amp; rect.bottom & lt; = document.body.scrollHeight & amp; amp; rect.right & lt; = (window .innerWidth | | Document.documentElement.clientWidth)); } Function changeMessage () {if (texter & amp; & amp; Today & amp; & amp; isElementInViewport (Today)) {texter.textContent = returnString ( "Šiandien", "Today", "Сегодня"); } Else {if (texter & amp; & amp; future & amp; & amp; isElementInViewport (forthcoming)) {texter.textContent = returnString ( "Artėjantys", "future", "Предстоящие"); } And (if (Techner & amp; amp; amp; & amp; amp ;; Element Invoice) (last)) {texter.textContent = returnString ("Praėję", "Past", "Прошлое")}}}} } Return return string {if (! (Typeof sessionvar === 'undefined')} {if (sessionvar == 'en_EN') {return en;} and if (sessionvar == 'ru_RU' } {Returns RU;}} Return LT;}  

The problem was that the Firefox report

  Document.body.scrollHeight  

As 0, because every if inside changeMessage () failed to return false.

The solution was found in SO:

Excerpt:

function getDocHeight () {var d = document; return Math.max (Math.max (D.body.scrollHyight, D.documentElement.scrollHyight) , Math.max (D.body.offsetHeight, D.documentElement.offsetHeight), Math.max (D.body.clientHeight, D .documentElement.clientHeight));}
< / Html>

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -