SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member akshay's Avatar
    Join Date
    Jul 2002
    Location
    India
    Posts
    16
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    adding images without the IMG tag?

    I am creating a page which shows a table of how compatible a CSS property is in different browsers.
    I am using images to show whether the property is fully compatible, partially compatible & not compatible.

    I want to know is there any way that instead of adding the the image code in each cell (<img src.....&gt,
    is it possible, say;

    all the image code is in a external Script
    and now when I want to insert the image in the webpage
    I just add some code, not the img tag, that calls the image code from the external Script.

    If its possible then please tell me know how do I go about it, as I dont know any scripting.

    Thanks
    Want quick & complete HTML & CSS reference?
    Come to http://tagsandstyles.tk

  2. #2
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: adding images without the IMG tag?

    Originally posted by akshay
    I am creating a page which shows a table of how compatible a CSS property is in different browsers.
    It's about time somebody updated on this.

    I want to know is there any way that instead of adding the the image code in each cell
    is it possible, say;

    all the image code is in a external Script
    and now when I want to insert the image in the webpage
    I just add some code, not the img tag, that calls the image code from the external Script.

    If its possible then please tell me know how do I go about it, as I dont know any scripting.

    Thanks
    document.write() should do what you need.

    Code:
    function putImage1() {
    document.write("<img src='tester.jpg' class='imgclass' />");
    }
    
    ...
    
    <script type="text/javascript">
    putImage1()
    </script>

    Of course, you could always use css itself.

    Give each of the effected td cells a class that uses a background-image.
    There'd be less code overhead (i.e. no need for repeated <script></script> tags) and it would also be more 'in keeping' with the purpose of the site.
    It would allow you to make the same kind of changes en masse just as the javascript option would.
    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature


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
  •