javascript - onclick load/run this code -


i trying create html file load/run following code on clicking button. had tried method below.

            <!-- custom -->             <div id="custom1">              </div>             <script>                 function custom()                 {                 var dummy = '<div id="custom1" style="display: block; position: absolute; top: 0px; left: 0px; z-index: 9999900; width: 100%; opacity: 0.8; height: 768px; visibility: visible;" ></div>                 <div id="custom1" style="display: block; text-align: center; line-height: normal; visibility: visible; position: absolute; top: 0px; left: 0px; z-index: 9999910; width: 100%; height: 667px;" ><div id="close_button_div" align="center" style="position: absolute; width: 100%; z-index: 9999930;"></div><div style="background: transparent; height: 768px; z-index: 9999915;">                     <iframe id="custom1" width="100%" height="768" id="overlay_iframe" src="" allowtransparency="true" frameborder="0" style="position: relative; height: 768px; overflow: hidden; z-index: 9999920; display: block; background-color: transparent;" scrollbars="no" ></iframe>                 </div>                 </div>                 <div id="custom1" align="center" style="position: absolute; width: 100%; z-index: 9999930;" ></div>                 <div id="custom1" style="background: transparent; height: 768px; z-index: 9999915;" >                     <iframe id="custom1" width="100%" height="768" id="overlay_iframe" src="captcha.php" allowtransparency="true" frameborder="0" style="position: relative; height: 768px; overflow: hidden; z-index: 9999920; display: block; background-color: transparent;" scrollbars="no">                     </iframe>                 </div>             </div>';                 document.getelementbyid('custom1').innerhtml += dummmy;                 }             </script>             <!-- end custom--> 

here code used button onclick

<a href="#" onclick="custom();">download</a> 

its not working me.

you have remove + sign before dummy. there variable name spelling mistake dummmy in code. here working code

 function custom()                  {                  var dummy= '<div id="custom1" style="display: block; position: absolute; top: 0px; left: 0px; z-index: 9999900; width: 100%; opacity: 0.8; height: 768px; visibility: visible;" ></div> <div id="custom1" style="display: block; text-align: center; line-height: normal; visibility: visible; position: absolute; top: 0px; left: 0px; z-index: 9999910; width: 100%; height: 667px;" ><div id="close_button_div" align="center" style="position: absolute; width: 100%; z-index: 9999930;"></div><div style="background: transparent; height: 768px; z-index: 9999915;"> <iframe id="custom1" width="100%" height="768" id="overlay_iframe" src="" allowtransparency="true" frameborder="0" style="position: relative; height: 768px; overflow: hidden; z-index: 9999920; display: block; background-color: transparent;" scrollbars="no" ></iframe>  </div> </div>                <div id="custom1" align="center" style="position: absolute; width: 100%; z-index: 9999930;" ></div>  <div id="custom1" style="background: transparent; height: 768px; z-index: 9999915;" ><iframe id="custom1" width="100%" height="768" id="overlay_iframe" src="captcha.php" allowtransparency="true" frameborder="0" style="position: relative; height: 768px; overflow: hidden; z-index: 9999920; display: block; background-color: transparent;" scrollbars="no">  </iframe> </div>  </div>';                  document.getelementbyid('custom1').innerhtml = dummy;                  }
 <div id="custom1">   </div>   <a href="#" onclick="custom();">download</a>


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -