Results 1 to 4 of 4

Thread: DOM Element error

  1. #1
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    381
    Thanks
    6
    Thanked 35 Times in 33 Posts

    Default DOM Element error

    Problem: Im using DOM element to change the layout of this page; however, the div element is the error

    Code:
    javascript:var ss1 = document.createElement('style');
    var def = 'body {background-image: url(http://imageshack.us/m/268/2272/skyorange.jpg);background-repeat:no-repeat; background-color:black;}#topContainer, .top_shadow, .top_bar{display:none;}#fake_links {color: red; position: absolute; top:0; left:0; width:100%; min-width: 1500px height: 50px; border-bottom: 1px solid red; background-color: black; box-shadow: 0px 2px 10px 2px red; -moz-box-shadow: 0px 2px 10px 2px red; -webkit-box-shadow: 0px 2px 10px 2px red;border-bottom: 1px solid white;}#nav{color: white; width: 75%; min-width: 880px; margin: auto; margin-top: 36px;  height: 24px;}#nav a{color: none;}#nav a:hover{color: none;}#ul_links li{cursor: pointer;}#ul_links{padding:5px; margin:0; list-style:none;}#ul_links > li{float: left; margin-left: 5px;	border:1px solid white; border-bottom: none; padding-left: 7px; padding-right: 7px; padding-top: 2px; padding-bottom: 2px; border-radius: 5px 5px 0px 0px; text-transform: uppercase; font-weight: bold;}#ul_links > li:hover{text-decoration: underline; background-color: red;}#ul_links li > ul{display: none; position: absolute; list-style:none; padding: 0; margin: 0; margin-top: 2px; margin-left: -8px; border: 1px solid white; width: 200px;border-bottom: none;text-transform:none; font-weight: 500;}#ul_links li:hover > ul{display: block;}#ul_links li > ul li{background-color: black; height:20px; line-height: 20px; border-bottom: 1px solid white;padding-left: 1px;}#ul_links li > ul li:hover:before{content: \'> \'; color: red;}#ul_links li > ul li:hover{background-color: #CCC; color: black;}';
    ss1.setAttribute("type", "text/css");
    var hh1 = document.getElementsByTagName('head')[0];
    hh1.appendChild(ss1);
    if (ss1.styleSheet)
    {ss1.styleSheet.cssText = def;}
    else
    {var tt1 = document.createTextNode(def);
    ss1.appendChild(tt1);}
    
    var main_div = document.createElement('div');
    main_div.id = "fake_links";
    var final = '<div id="nav"><ul id="ul_links"><li>Overviews<ul><li>Combined</li><li>Production</li><li>Transport</li><li>Troops</li><li>Commands</li><li>Incoming</li><li>Buildings</li><li>Research</li><li>Groups</li><li>Account Manager</li></ul></li><li>Reports<ul><li>All reports</li><li>Attacks</li><li>Defenses</li><li>Support</li><li>Trade</li><li>Miscellaneous</li><li>Forwarded</li><li>Filter</li><li>Block sender</li><li>Publicized reports</li><li>Folders</li></ul></li><li>Mails<ul><li>Mail</li><li>Circular mail</li><li>Write message</li><li>Block sender</li><li>Address book</li><li>Folders</li></ul></li><li>Tribe<ul><li>Overview</li><li>Profile</li><li>Members</li><li>Diplomacy</li><li>Wars</li><li>Noble planner</li><li>Recruitment</li><li>Welcome</li><li>Properties</li><li>Tribal forum</li></ul></li><li>Ranking<ul><li>Tribes</li><li>Players</li><li>Continent Tribes</li><li>Continent Players</li><li>Opponents defeated (tribe)</li><li>Opponents defeated</li><li>Awards</li><li>Wars</li></ul></li><li>Settings<ul><li>Profile</li><li>Settings</li><li>Notifications</li><li>Edit quick bar</li><li>Awards</li><li>Share Internet connection</li><li>Account Sitting</li><li>Logins</li><li>Surveys</li><li>Invite players</li><li>To the mobile version</li><li>Toolbar</li><li>iOS & Android</li><li>Block player</li><li>Voucher codes</li><li>Support ticket</li></ul></li><li>Premium<ul><li>Redeem</li><li>Purchase</li><li>Transfer</li><li>Log</li></ul></li><li>Notebook</li><li>Logout</li></ul></div>';
    main_div.innerHTML = final;
    document.body.appendChild(main_div);
    Error in creating the div element.
    Thanks,
    -DW
    Last edited by Deadweight; 09-24-2013 at 07:40 AM. Reason: Div element error

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,167
    Thanks
    44
    Thanked 3,240 Times in 3,201 Posts
    Blog Entries
    12

    Default

    I'm not getting any errors. Do I have to click on something or do something else to get the error?

    Oh and, since it looked like the code was addressing the body, I put it in the body of the page. That might be all you need to do to fix it.

    Here's a working demo:

    http://home.comcast.net/~jscheuer1/s...kid69/domh.htm
    Last edited by jscheuer1; 09-27-2013 at 05:42 AM. Reason: add demo
    - John
    ________________________

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

  3. #3
    Join Date
    Mar 2010
    Location
    Florida
    Posts
    381
    Thanks
    6
    Thanked 35 Times in 33 Posts

    Default

    Its actually a weird error from something else. It would work by itself but doesnt work if i make it a link. I know doesnt make any sense xD

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    29,167
    Thanks
    44
    Thanked 3,240 Times in 3,201 Posts
    Blog Entries
    12

    Default

    That might be. I think the error is because, if the script is in the head, there's no body to append to yet. But, as I say, it might be what you're saying.

    If you could put up a demo somewhere on the web that shows the error you're talking about and post a link to it here, I can probably pinpoint the issue.
    - John
    ________________________

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

Similar Threads

  1. Resolved Ajax loaded element not recognized in ajax post send(element)?
    By crobinson42 in forum JavaScript
    Replies: 6
    Last Post: 04-10-2012, 08:48 PM
  2. Get element by name error
    By keyboard in forum JavaScript
    Replies: 6
    Last Post: 08-10-2011, 11:05 PM
  3. Replies: 3
    Last Post: 11-10-2010, 05:38 PM
  4. Replies: 5
    Last Post: 11-19-2008, 04:02 AM
  5. Changing the first TR element to THEAD element
    By codeexploiter in forum JavaScript
    Replies: 3
    Last Post: 03-23-2007, 11:02 AM

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
  •