Results 1 to 2 of 2

Thread: document.write PROBLEMS

  1. #1
    Join Date
    Apr 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default document.write PROBLEMS

    Hi, I'm new on forum.

    Anyway, I have this code but it doesn't work.
    If I remove the CSS in the document.write function it works fine.
    I have tried moving background:url(); to background='' in the anchor but that still doesn't work.

    Code:
    function generate(){
    
    var user = document.getElementById('user').value;
    
    document.write("<style type='text/css'>
    .subscribe {
    font-family:Arial;
    background:url(subscribe.png) no-repeat;
    font-weight:bold;
    width:80px;
    height:25px;
    padding:5px 12px 5px 8px;
    color:#994800;
    text-decoration:none;
    }
    .subscribe:hover {
    text-decoration:underline;
    }
    </style>
    <a href='http://youtube.com/subscription_center?adduser="+ user +"' class='subscribe'>Subscribe</a>");
    
    }
    Thanks for any help given!!!

  2. #2
    Join Date
    Sep 2007
    Location
    The Netherlands
    Posts
    1,881
    Thanks
    49
    Thanked 266 Times in 258 Posts
    Blog Entries
    56

    Default

    If you want to write styles, the code must have the following form:
    Code:
    document.write('<style type="text/css">');
    document.write('.subscribe {font-family:comic sans ms;text-decoration:none;background-color:transparent;font-size:11px;}');
    document.write('</style>');
    Moreover, putting the document.write in a function makes no sense, since applying the function after page load overwrites everything on the page.
    ===
    Arie.

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
  •