javascript - Calling function from div and link not working -


i have code below. works on mobile device reason, baffles me, won't work in desktop browser. ideas?

<div class="top_nav_option_wrapper"    onclick="javascript:changepage('{{ shop.url }}{{ link.url }}','fade');">   <a href="#"    onclick="javascript:changepage('{{ shop.url }}{{ link.url }}','fade');"    class="top_nav_option">{{ link.title }}</a><br> </div> 

function

  // function used transition page out , navigate new page   function changepage(gotourl, type, id) {     alert('hey');     if (type == 'collection_flicker') {         prodelements = ['prod1', 'prod2', 'prod3', 'prod4'];         (i = 0; < prodelements.length; i++) {             if (document.getelementbyid(prodelements[i]) != null && document.getelementbyid(prodelements[i]) != document.getelementbyid(id)) {                 document.getelementbyid(prodelements[i]).style.opacity = "0";                 document.getelementbyid(prodelements[i]).style.display = "none";             }         }         flickereffect('collection_exit', 15, 50);         window.settimeout(function () {             window.location.href = gotourl         }, 1000);     } else if (type == 'fade' && currenttemplate == 'collection') {         document.getelementbyid('watermark').style.transition = '1s opacity';         document.getelementbyid('watermark').style.opacity = '0';         document.getelementbyid('productcollectionlist').style.transition = '1s opacity';         document.getelementbyid('productcollectionlist').style.opacity = '0';         window.settimeout(function () {             window.location.href = gotourl         }, 500);     } else {         window.location.href = gotourl;     }   } 

i suggest following changes - not sure how link.url becomes type see idea

html:

<div class="top_nav_option_wrapper">   <a href="{{ shop.url }}"    onclick="return changepage(this.href,'{{ link.url }}','fade');"    class="top_nav_option">{{ link.title }}</a><br> </div> 

script

// function used transition page out , navigate new page function changepage(gotourl, type, id) {    if (type == 'collection_flicker') {     prodelements = ['prod1', 'prod2', 'prod3', 'prod4'];     (var = 0; < prodelements.length; i++) {       var prodelem = document.getelementbyid(prodelements[i]);            if (prodelem != null && prodelem  != document.getelementbyid(id)) {         prodelem.style.opacity = "0";         prodelem.style.display = "none";       }     }     flickereffect('collection_exit', 15, 50);     window.settimeout(function () {         window.location.href = gotourl     }, 1000);     return false; // cancel link   } else if (type == 'fade' && currenttemplate == 'collection') {     document.getelementbyid('watermark').style.transition = '1s opacity';     document.getelementbyid('watermark').style.opacity = '0';     document.getelementbyid('productcollectionlist').style.transition = '1s opacity';     document.getelementbyid('productcollectionlist').style.opacity = '0';     window.settimeout(function () {         window.location.href = gotourl     }, 500);     return false; // cancel link   }    return true; // allow link } 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -