#1
  1. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Chicago, USA
    Posts
    73
    Rep Power
    14

    Unhappy


    Before I ask my question please use the following URL's as reference b/c this may sound a bit confusing:

    http://www.digitalbait.com/product_i...roducts_id=35&

    http://www.digitalbait.com/Outward/r...%253D580214895

    The first URL is the products page and the second URL is the page of the product on an external site with a top frame linking back to my site. I have a button in the top frame that mail the URL (everything after ?url=) to a designated address using the mail(); function.

    When the button on the top frame is clicked a new window opens notifying the user that the URL was sent. The way I originally had it written was to have a new browser window open with <target="_blank"> but I wanted to use javascript instead so I could control the size of the popup.

    Without javascript the full URL was sent just fine but now that I implemented the javascript only part of the URL is being sent. urlencode is supposed to take care of this problem (which it does without javascript). Here is the original code and also the current code:

    Original code:
    Code:
    <html>
    <head>
    	<title>Thanks for using DigitalBait</title>
    </head>
    <?php 
    $qs = "?url=" . urlencode($url);
    $URL = "broken_link.php" . $qs;
    ?>
    <form method="post" action="<? echo($URL); ?>" target="_blank">
    ...rest of page...
    <input type="image" name="submit" src="/images/frame/submit_link.gif" border="0" vspace="2" hspace="5">
    Current code:
    Code:
    <html>
    <head>
    	<title>Thanks for using DigitalBait</title>
    </head>
    <SCRIPT LANGUAGE="JavaScript">
    function popUp(url) {
    sealWin=window.open(url,"win",'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=1,width=300,height=75');
    self.name = "mainWin"; }
    </SCRIPT>
    <?php 
    $qs = "?url=" . urlencode($url);
    $URL = "broken_link.php" . $qs;
    ?>
    <form method="post" action="javascript:popUp('<? echo($URL); ?>')">
    ...rest of page...
    <input type="image" name="submit" src="/images/frame/submit_link.gif" border="0" vspace="2" hspace="5">
    The popUp window displays the following:
    Code:
    <html>
    <body bgcolor="#cc6600">
    <font face="verdana" size="2" color="white">
    
    <?php
    $to = "me@myaddress.com";
    $subj = "Broken Link Report";
    $body = $url;
    
    $success = mail ($to, $subj, $body);
    if ($success) {
    echo ("The problem link was sent and we will get it fixed as soon as possible.  Thank you for your cooperation.");
    } else {
    echo ("Error sending mail.  Please resubmit link.");
    }
    ?>
    </font>
    <br>
    <div align="right"><FORM><font face="verdana" size="1" color="white">Close Window:&nbsp;<INPUT TYPE='BUTTON' VALUE='x' onClick='window.close()'></FORM></div>
    </body>
    </html>
    What is it about the javascript that wont let urlencode do its job? I'm pulling my hair out over this one... Thanks in advance.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2001
    Location
    UK
    Posts
    527
    Rep Power
    14
    I guess yoy don't want to be using post to submit to a javascript function. Try something like this:

    <form>
    ...rest of page...
    <input type="image" name="submit" src="/images/frame/submit_link.gif" border="0" vspace="2" hspace="5" onClick="popUp(<? echo($URL); ?>)">
    </form>

    ie. use the onClick of the image to call the jscript. I may have missed some ' or "

    John
  4. #3
  5. No Profile Picture
    Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2000
    Location
    Chicago, USA
    Posts
    73
    Rep Power
    14

    Thumbs up


    JohnB,
    Thanks a lot, that did the trick. I'm still trying to understand why but I guess it doesn't matter now that it is working.

IMN logo majestic logo threadwatch logo seochat tools logo