Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2008
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Javascript code not working in IE

    can someone help me with why this won't work in IE?

    Code:
    <script type="text/javascript">
    			var d = document;
    			function set_random_background(where) {
    				var backgrounds = [
    					["back1.png", "#000000"],
    					["back2.png", "#000000"],
    				];
    				var index = Math.floor(Math.random() * backgrounds.length);
    				var style_element = d.createElement("style");
    				style_element.setAttribute("type", "text/css");
    				style_element.setAttribute("media", "all");
    				d.getElementsByTagName("body").item(0).appendChild(style_element);
    				style_element.sheet.insertRule("#"+where+" { background: " + backgrounds[index][1] + " url(\"" + backgrounds[index][0] + "\") center top no-repeat scroll; }", 0);
    			}
    			(function verify_URI() {
    				var ignore = false;
    				var directory_blacklist = [
    					"profile\/username\/",
    					"profiles\/",
    					"xn\/"
    				];
    				for (var i = 0; i < directory_blacklist.length; i++) {
    					if (new RegExp("^http:\/\/www\.example\.org\/" + directory_blacklist[i]).test(d.URL)) {
    						ignore = true;
    					}
    				}
    				if (ignore === false) {
    					set_random_background('somedivid');
    				}
    			})();
    		</script>
    Thanks!

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,866
    Thanks
    160
    Thanked 2,224 Times in 2,211 Posts
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)


  •  

    Posting Permissions

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