Results 1 to 2 of 2

Thread: Script doesn't work in FireFox

  1. #1
    Join Date
    Dec 2009
    Posts
    48
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Script doesn't work in FireFox

    1) Script Title: Live Background Previewer Script

    2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex3/document1.htm

    3) Describe problem: This script works fine in IE, but the script doesn't work in FireFox (version 3.5.6). Not the demo on DD and not on my own page.

    Just wanted to point that out. Or unless I need a specific plugin to let it work? If so, that might be useful to put that on the script page.


    This script has the same problem as mentioned above:
    -:: Gradient Bar (http://www.dynamicdrive.com/dynamicindex11/gradient.htm)
    Last edited by Bar2aYunie; 01-01-2010 at 09:50 PM. Reason: added script

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Neither of those scripts is rated for Firefox. So this is not a bug. But, instead of move this thread to the general help area, because they are both rated for Opera, and do not work in that browser, I'm leaving it here.

    Here's the fix for Opera (also now works in Firefox):

    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <style type="text/css">
    #theImages {
    	overflow: hidden;
    }
    #theImages br {
    	clear: left;
    }
    #theImages img {
    	cursor: pointer;
    	float: left;
    	display: block;
    }
    </style>
    <!--[if lt IE 6]>
    <style>
    #theImages img {
    	cursor: hand;
    }
    </style>
    <![endif]-->
    <script type="text/javascript">
    
    /*
    Live Background Previewer Script- 
    © Dynamic Drive (www.dynamicdrive.com)
    For full source code, installation instructions,
    100's more DHTML scripts, and Terms Of
    Use, visit dynamicdrive.com
    */
    
    (function(addEvent){
    
    	function tile(e, source){
    		e = e || window.event;
    		e.cancelBubble = true;
    		source = e.target || e.srcElement;
    		if(source.tagName && source.tagName.toLowerCase() === 'img'){
    			document.body.style.backgroundImage = 'url(' + source.src + ')';
    		}
    	}
    	
    	function restore(){
    		document.body.style.backgroundImage = '';
    	}
    	
    	function init(){
    		addEvent(document, 'click', restore);
    		addEvent(window, 'load', function(){
    			addEvent(document.getElementById('theImages'), 'click', tile);
    		});
    	};
    	
    	if(document.getElementById){
    		init();
    	}
    
    })((function(){
    	return window.addEventListener? function(el, ev, f){
    		el.addEventListener(ev, f, false);
    	} : window.attachEvent? function(el, ev, f){
    		el.attachEvent('on' + ev, f);
    	} : function(){return;};
    })());
    </script>
    </head>
    <body>
      <div>
        <span id="theImages">
          <img src="backgr10.jpg" alt="">
          <img src="backgr11.jpg" alt="">
          <br>
          <img src="backgr13.jpg" alt="">
          <img src="backgr14.jpg" alt="">
        </span>
      </div>
    </body>
    </html>
    Last edited by jscheuer1; 01-02-2010 at 08:25 AM. Reason: add fix
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. The Following User Says Thank You to jscheuer1 For This Useful Post:

    Bar2aYunie (01-03-2010)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •