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 4 of 4
  1. #1
    New Coder
    Join Date
    Jun 2013
    Posts
    20
    Thanks
    15
    Thanked 0 Times in 0 Posts

    Code reads URL to display image, but need to display text

    I have been using the code below to display an image when the URL contains a key word. I'd like to ask for help in changing this code to display text instead of an image. And with the text, have the ability to change the font, size and color of the text. This change would allow me to add more relevant data to my page to help the end-user. Any help would be appreciated.

    [BEGIN CODE]
    <style type="text/css">
    img.dyn { display: none; }
    [url*="smead"] img.dyn.smead { display: block; }
    [url*="brother"] img.dyn.brother { display: block; }
    [url*="hp"] img.dyn.hp { display: block; }
    [url*="energizer"] img.dyn.energizer { display: block; }
    </style>



    <a href="/Images/rebates/smead_gascard_7.1.13.pdf">
    <img class="dyn smead" src="/Images/rebates/rebate_banner_smead.png">
    <a href="/Images/rebates/brother_banner.pdf">
    <img class="dyn brother" src="/Images/rebates/rebate_banner_brother.png">
    <a href="/Images/rebates/hp_kohls15_7.1.13(2).pdf"> <img class="dyn hp" src="/Images/rebates/rebate_banner_hp.png">
    <a href="/Images/rebates/energizer_visacard_7.1.13.pdf"> <img class="dyn energizer" src="/Images/rebates/rebate_banner_energizer.png">
    </a>

    <script type="text/javascript">
    var url = decodeURIComponent(location.search).toLowerCase();
    document.body.setAttribute("url", url );
    </script>
    <br />
    [END CODE]

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,033
    Thanks
    0
    Thanked 248 Times in 245 Posts
    Just change the img to div.
    Code:
    <style type="text/css">
    div.dyn { display: none; }
    [url*="smead"] div.dyn.smead { display: block; }
    [url*="brother"] div.dyn.brother { display: block; }
    [url*="hp"] div.dyn.hp { display: block; }
    [url*="energizer"] div.dyn.energizer { display: block; }
    </style>
    
    <div class="dyn smead">This is smead</div>
    <div class="dyn brother">This is brother</div>
    <div class="dyn hp">This is hp</div>
    <div class="dyn energizer">This is energizer</div>

  • Users who have thanked glenngv for this post:

    tybrantt (10-09-2013)

  • #3
    New Coder
    Join Date
    Jun 2013
    Posts
    20
    Thanks
    15
    Thanked 0 Times in 0 Posts

    thanks for making this easier than I thought

    div, I'm embarrassed I missed that. But here's one more question that came up. How can I change the code to read a specific address in the url instead of keywords? Currently the code looks for a keyword [url*="smead"]. What do i need to change to get the code to be more specific and read the entire url address?

    Something like [http://www.abccompany.com/Products/Micropore-Stamp-Pad--4-14-x-2-34--Black__AVE21281.aspx]

    Or am I better off using part of the url address?

    like [Products/Micropore-Stamp-Pad--4-14-x-2-34--Black__AVE21281]

    i dont know if being more specific or less specific is the wisest longterm solution

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,033
    Thanks
    0
    Thanked 248 Times in 245 Posts
    Since you are using a server-side language (ASP.NET), why not do it there?


  •  

    Tags for this Thread

    Posting Permissions

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