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 5 of 5
  1. #1
    New Coder
    Join Date
    May 2004
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    script to set page bg image

    For an IE-based offline WYSIWYG editor, I have added javascript to insert images as table backgrounds and to set page background color. But I can't get any script to work for setting a page background image.

    I use a form with a button input type="file" for the user to select a page background image from his hard drive and a second button with onClick to launch this script:

    function backImg() {
    var img = form2.imgurl.value;
    var body = "<BODY style='BACKGROUND: + img + '>";
    iView.focus();
    iView.document.write(body);
    }

    But I get this HTML when the page is saved:

    <BODY style="BACKGROUND: none transparent scroll repeat 0% 0%"></BODY>

    The MSHTML control is ignoring the img input and I can't figure out how to get around this problem. I've tried dozens of variations of the script, but none work. Any ideas?

    PS: I have to use BODY style= rather than body background= because it's proprietary in MSHTML.

  • #2
    Regular Coder
    Join Date
    Jun 2004
    Location
    underground
    Posts
    186
    Thanks
    0
    Thanked 0 Times in 0 Posts
    iView.document.body.style.backgroundImage="url(WYSWYGGY.jpg)"

  • #3
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by neofibril
    iView.document.body.style.backgroundImage="url(WYSWYGGY.jpg)"
    Good golly! Do you think he'll see it? LOL

  • #4
    New Coder
    Join Date
    May 2004
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by neofibril
    iView.document.body.style.backgroundImage="url(WYSWYGGY.jpg)"
    Thanks for nothing.

  • #5
    Regular Coder
    Join Date
    Jun 2004
    Location
    underground
    Posts
    186
    Thanks
    0
    Thanked 0 Times in 0 Posts
    any time...


  •  

    Posting Permissions

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