Hello,

I am having what i am sure is a simple issue for most people. I am trying to do two actions when a href link is clicked on my site.

First action is that it opens up the specified url in a new window.

Second Action is that it post's a data to search string.

The issue i am currently having is that all my links are stored in a mysql DB and called dynamically onto the page using ajax(prototype).

This is part of my backend scirpt to get the required information from the DB and display it.

echo ("<P><DT><B>$titlename</B><BR>\n");
while ($row = mysql_fetch_array($retid)) {
$siteurl = $row["siteurl"];
$sitename = $row["sitename"];

echo ("<DD><A HREF='$siteurl'target='_blank' >$sitename</A></DD>\n");
}
echo ("</DT></P>");
}

I know it is very simple but it works perfectly.

Now what would i have to do so that when a user click's any given link that is displayed

it will post to a search string with the $sitename variable put in at the end.

It would look something like this

http://www.example.com/SearchMode=$sitename

This would be done in the backend and the user would never see it.

Any help would be greatly appretiated.

Thanks Everyone.

    You could do something like this.

    $full_url = $siteurl."?SearchMode=".$sitename;
    echo "<dd>< a href=\"$full_url\" target=\"_blank\">$sitename</a></dd>\n";
    

      You may want to consider an option other than the target attribute. It is supported in HTML 4.01 and Transitional XHTML, but is deprecated in XHTML Strict compliane. (A javascript window open funtion perhaps, since that's about the only alternative available for XHTML Strict compliance.)

      Now, if strict XHTML compliance isn't a concern, then tron00's solution should work for you fine. If you want to code for future planning (when browsers will no longer support HTML 4.01 or Transitional XHTML, then you now have enough information in my reply to begin searching for how to do it.

        TheDefender wrote:

        You may want to consider an option other than the target attribute. It is supported in HTML 4.01 and Transitional XHTML, but is deprecated in XHTML Strict compliane. (A javascript window open funtion perhaps, since that's about the only alternative available for XHTML Strict compliance.)

        Now, if strict XHTML compliance isn't a concern, then tron00's solution should work for you fine. If you want to code for future planning (when browsers will no longer support HTML 4.01 or Transitional XHTML, then you now have enough information in my reply to begin searching for how to do it.

        Yes, I would have to agree.

          Thank you for your Reply,

          Tron00- I am unsure how what you wrote up will work correctly, The string that i am trying to post and append a search query to is alternate from the string that is clicked.

          $siteurl is the link that a user will click, to open up a specified page.

          I am just unsure how full_url will be passed in the back without the user seeing it and why full_url is equal to $siteurl

          Any more information would be great.

            DefunctExodus,

            I bet someone knows a really simple and sexy way for this to happen, but I've always assumed that this was what sites like hotscripts and such were doing when it was sending you to a page that told you it was "sending you to the page". Your link is going to the site, but why not have it go to:

            yoursite.com/logger.php?siteid=102

            where logger.php would do absolutely anything you wanted it to do, then forward the user on to the intended site. You could have it open in a j/s popup that closed after forwarding, or you could have it open in a new window, so your user wouldn't leave your site and have the resulting link in a separate tab or window.

            This is a very simple resolution, but it seems pretty trouble-free and invisible.

            thanks,
            json

              Write a Reply...