Does anyone know of a script that will do this?

Discussion in 'Programming' started by venrooy, Oct 19, 2007.

  1. #1
    I need a script that will hide - or not show an image until the page is refreshed. When the refresh button on the browser is hit - the picture appears.


    I've seen it done, but the script was hidden. Does anyone know how to do this?

    Thanks.
     
    venrooy, Oct 19, 2007 IP
  2. gopher292

    gopher292 Peon

    Messages:
    64
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    I tried to find out if this was possible with javascript, but it doesn't seem to be.

    This should work if you have php and the user has cookies enabled:
    <?
    if($_COOKIE['reloadcheck292']==1) {
    ?>
    
    //PAGE CONTENT WITHOUT IMAGE
    
    <?
    } else {
     setcookie("reloadcheck292", "1", time()+3600*12);
    ?>
    
    //PAGE CONTENT WITH IMAGE
    
    <?
    }
    ?>
    
    Code (markup):
    I've been working on this for about 20 minutes, so rep would be nice. :D

    Hope this helps you.
     
    gopher292, Oct 19, 2007 IP
  3. venrooy

    venrooy Active Member

    Messages:
    804
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    80
    #3
    I'm pretty much a scripting nube - can you show me that script with the page urls (w/ and w/out image) in it. I'm unsure where to put them.

    Thanks.
     
    venrooy, Oct 19, 2007 IP
  4. gopher292

    gopher292 Peon

    Messages:
    64
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The page url is the same as what your original page was.

    (Here's a better solution):
    <?php
    //(PUT THIS AT THE TOP OF THE FILE)
    if($_COOKIE['reloadcheck292']==1) {
     $pageisbeingreloaded=1;
    } else {
     setcookie("reloadcheck292", "1", time()+3600*12);
     $pageisbeingreloaded=0;
    }
    ?>
    
    //PUT YOUR EXISTING PAGE CODE UP TO THE PART WITH THE IMAGE YOU WANT TO HIDE OR SHOW
    
    <?php if($pageisbeingreloaded=1) echo '<img src="(image url you want to hide or show)">'; ?>
    
    //PUT THE REST OF YOUR PAGE HERE
    
    ?>
    Code (markup):
     
    gopher292, Oct 19, 2007 IP
  5. venrooy

    venrooy Active Member

    Messages:
    804
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    80
    #5
    That's excellent - How can I pay you?
     
    venrooy, Oct 19, 2007 IP
  6. gopher292

    gopher292 Peon

    Messages:
    64
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #6
    If you want to pay me, my e-gold account is 3693814 (my paypal is limited right now :( ). Or you could add to my forum rep at least. Whatever you think is fair... *shrug*

    Glad to help.
     
    gopher292, Oct 19, 2007 IP
  7. venrooy

    venrooy Active Member

    Messages:
    804
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    80
    #7
    Shoot - Just tried it out and doesn't seem to be working right.

    Maybe you can check it out for me and see if I'm doing something wrong


    http://skidmarknews.com/test.php
     
    venrooy, Oct 19, 2007 IP
  8. venrooy

    venrooy Active Member

    Messages:
    804
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    80
    #8
    Here is my code:

    <?php
    //(PUT THIS AT THE TOP OF THE FILE)
    if($_COOKIE['reloadcheck292']==1) {
    $pageisbeingreloaded=1;
    } else {
    setcookie("reloadcheck292", "1", time()+3600*12);
    $pageisbeingreloaded=0;
    }
    ?>

    <head>
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 4</title>
    </head>

    <body>
    Testing Testing 123
    <?php if($pageisbeingreloaded=1) echo '<img src="http://criticolatino.files.wordpress.com/2007/06/vanessa-hudgens-picture-1.jpg">'; ?>
    test
    </body>

    </html>
     
    venrooy, Oct 19, 2007 IP
  9. gopher292

    gopher292 Peon

    Messages:
    64
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #9
    try replacing if($_COOKIE['reloadcheck292']==1) {
    with if($_COOKIE['reloadcheck293']=="1") {

    and setcookie("reloadcheck292", "1", time()+3600*12);
    with setcookie("reloadcheck293", "1", time()+3600*12);

    (note: you can reduce the max amount of time between reloads by changing the number part of "time()+3600*12" (it's in seconds -- 3600*12=12 hours))
     
    gopher292, Oct 19, 2007 IP
  10. venrooy

    venrooy Active Member

    Messages:
    804
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    80
    #10
    hmm - still not working.
     
    venrooy, Oct 19, 2007 IP
  11. gopher292

    gopher292 Peon

    Messages:
    64
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #11
    Oh, wait, here's the bug:

    it should be if($pageisbeingreloaded==1)...

    so:
    
    <?php
    //(PUT THIS AT THE TOP OF THE FILE)
    if($_COOKIE['reloadcheck294']==1) {
    $pageisbeingreloaded=1;
    } else {
    setcookie("reloadcheck294", "1", time()+3600*12);
    $pageisbeingreloaded=0;
    }
    ?>
    
    <head>
    <meta name="GENERATOR" content="Microsoft FrontPage 5.0">
    <meta name="ProgId" content="FrontPage.Editor.Document">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>New Page 4</title>
    </head>
    
    <body>
    Testing Testing 123
    <?php if($pageisbeingreloaded==1) echo '<img src="http://criticolatino.files.wordpress.com/2007/06/vanessa-hudgens-picture-1.jpg">'; ?>
    test
    </body>
    
    </html>
    
    Code (markup):
     
    gopher292, Oct 19, 2007 IP
  12. gopher292

    gopher292 Peon

    Messages:
    64
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #12
    I disconnected and started a server on my pc and tested that just to make sure too. :p
     
    gopher292, Oct 19, 2007 IP
  13. venrooy

    venrooy Active Member

    Messages:
    804
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    80
    #13
    That worked. That's exactly what I wanted. I don't have an egold account. Is there a way to send me a bill with egold that I can pay w/ credit card?

    Also I've added to your rep. Thanks.
     
    venrooy, Oct 19, 2007 IP