How to do this in javascript/php?

IT.com

shakemelikeapig

New Member
I'm trying to show a certain link on my status bar and when the person clicks it it goes to a different one.

The code I've put so far is this:

Code:
 <script language="javascript" type="text/javascript">     function redirect(URL)     {       document.location=URL;       return false;     }    </script><center><h2><a href="http://www.showthislink.org/download/<?php the_title(); ?>.zip" onclick="returnredirect('http://www.gotothislink.com') rel="nofollow"><font color="FF0000"> Click Here to Download <?php the_title(); ?></font></center></a></h2>

This is how it looks on my single.php page in wordpress.

I dont know much about coding, I just search google and read about code that I want to to use. Do I have to put any special code on the top of the page to let it know that I'll be using javascript later?


I got the code above from this site: Code:

Code:
http://roshanbh.com.np/2008/08/different-status-bar-text-hyperlink-mouseover.html




IM
 
if you have ftp access to your server, where you host your site showthislink.org,

create a new text file in your computer named index.php and place the following one line code in it.

<?php header( 'Location: http://www.gotothislink.com' ); ?>

now create a new folder named "download" on showthislink.org server via ftp in its folder public_html.
Upload the index.php we created to this folder.

Now any link pointing to "http://showthislink.org/download" will redirect the user to http://www.gotothislink.com, but on mouseover, link will show "http://showthislink.org/download".

Let me know if you have any questions..

Assumptions:
-You want to show user that the link is pointing to showthislink.org
-You have ftp access to this showthislink.org server and it is php enabled(which 99.9% servers are).
-No need to do anything on the gotothislink.com server/website
-
 
To make your existing code to work, you have to rectify these two problems

1-Following code should be in between <head></head> tags, in header.php file of wordpress current theme instead of single.php
Code:
<script language="javascript" type="text/javascript">
function redirect(URL){
  document.location=URL;
  return false;
  }
</script>

Leave the remaining code as it is in single.php
Code:
<center>
<h2>
<a href="http://www.showthislink.org/download/<?php the_title(); ?>.zip" onclick="return redirect('http://www.gotothislink.com') rel="nofollow">
<font color="FF0000"> Click Here to Download <?php the_title(); ?></font>
</center></a>
</h2>


2-There should be a space between "returnredirect" as "return redirect"

But beware, if user has disabled Javascript, browser will open only showthislink.org.
The trick will work only if JS is enabled. But the php solution in my previous post is not browser dependent and has same functionality.
 

whois



Forums dedicated to Indian domain names, including buying, selling, appraising, developing, and monetizing.

About Us

Threads
29,389
Messages
76,794
Members
7,950
Latest member
rahul mehta
Top Bottom