Current location: Hot Scripts Forums » General Community » Script Requests » External link to open in same page


External link to open in same page

Reply
  #1 (permalink)  
Old 03-25-07, 09:34 PM
sparkiii sparkiii is offline
New Member
 
Join Date: Mar 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Exclamation External link to open in same page

Hi I am setting up a pretty basic HTML site, but it is working on gaining adsense revenue, so therefor my question is-

How can I make an external link open within the same page so the the adsence still remains on my page and is relevent to the information on the new external url that has opened.

I have seen it work here
http://easyhouses.com.au/firsthome.php

Thanks in advance.

Nat
Reply With Quote
  #2 (permalink)  
Old 03-26-07, 03:30 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Here is a simple table that will display one of three pages. Of course you could do a lot more than this does.
Example:
PHP Code:

<?php

// Note: "page_no" is the name of a hidden input in the form.

$next_page $_POST["page_no"]; 
   

// Set the default page.

if(!$next_page){$next_page 1;} 
   

// This form used for submitting page number.

echo("<form name=\"theform\" action=\"#\" method=\"POST\">");
echo(
"<input id=\"p_no\" type=\"hidden\" name=\"page_no\">");
echo(
"</form>");

// I am using a table to display the different pages.
// But the possibilities are endless.

echo("<table rules=\"all\" style=\"width:100%;border:solid 1 #000000;\">");
echo(
"<tr>");
echo(
"<td width=\"40%\"></td>");
echo(
"<td>");
echo(
"<button onclick=\"document.getElementById('p_no').value = 1;theform.submit();\">Page 1</button>");
echo(
"</td>");
echo(
"<td>");
echo(
"<button onclick=\"document.getElementById('p_no').value = 2;theform.submit();\">Page 2</button>");
echo(
"</td>");
echo(
"<td>");
echo(
"<button onclick=\"document.getElementById('p_no').value = 3;theform.submit();\">Page 3</button>");
echo(
"</td>");
echo(
"<td width=\"40%\"></td>");
echo(
"</tr>");
echo(
"<tr>");
if(
$next_page == 1)
{
 echo(
"<td colspan=\"5\">");
 echo(
"This is page 1. You can put anything here that you want.");
 
// require("page_1.php");    // Enable this line to include an external page.
 
echo("</td>");
 }
if(
$next_page == 2)
{
 echo(
"<td colspan=\"5\">");
 echo(
"This is page 2. Put something else here.");
 
// require("page_2.php");    // Enable this line to include an external page.
 
echo("</td>");
 }
if(
$next_page == 3)
{
 echo(
"<td colspan=\"5\">");
 echo(
"This is page 3. This is the last page for this demo.");
 
// require("page_3.php");    // Enable this line to include an external page.
 
echo("</td>");
 }
echo(
"</tr>");
echo(
"</table>");
?>
__________________
Jerry Broughton

Last edited by job0107; 03-26-07 at 03:34 AM.
Reply With Quote
  #3 (permalink)  
Old 03-26-07, 03:50 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
They're using an iFrame.

http://www.w3schools.com/tags/tag_iframe.asp


However, job0107's code should work as well. I wouldn't rely on Javascript though. You can use multiple submit buttons with different values to achieve the same.

Example:
HTML Code:
<form action="" method="post">

<input type="submit" name="page" value="1" />
<input type="submit" name="page" value="2" />
<input type="submit" name="page" value="3" />

</form>
Reply With Quote
  #4 (permalink)  
Old 03-26-07, 05:35 AM
sparkiii sparkiii is offline
New Member
 
Join Date: Mar 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
A bit more help.

Thanks very much for getting back to me so quickly, unbelievable

OK, with the PHP script ( I am quite new to PHP, I have changed a few scripts, but everytime I do I feel like I have fluked it to get it right)

I am trying to enable the line that says Enable this line to include an external page, by just taking out the //

echo("<td colspan=\"5\">");
echo("This is page 1");
require("http://www.in2media.com.au"); // Enable this line to include an external page.
echo("</td>");
}

But i get errors as shown here

http://www.cancermusic.org/test.php

Also is there any way of using this script just with text links as oppossed to the buttons.

Thanks again.

Natalie
Reply With Quote
  #5 (permalink)  
Old 03-26-07, 06:56 AM
bizzar528's Avatar
bizzar528 bizzar528 is offline
Community Liaison
 
Join Date: Sep 2004
Location: Pennsylvania, US
Posts: 1,550
Thanks: 2
Thanked 16 Times in 15 Posts
Replace this line:

PHP Code:

require("http://www.in2media.com.au"); 

with something like this:

PHP Code:

$ch curl_init("http://www.example.com/");

curl_setopt($chCURLOPT_HEADER0);
curl_exec($ch);
curl_close($ch); 
The require and include functions are sometimes disabled by webservers when accessing files remotely. I've used the curl function though to just read a remote site and display it back though.
__________________
Yep, it's a signature...
Reply With Quote
  #6 (permalink)  
Old 03-26-07, 07:15 AM
sparkiii sparkiii is offline
New Member
 
Join Date: Mar 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
This is the fastest replying forum I have been too....thanks.

I have got the iframe working (just trying to comparre the 2 examples given to me here) at http://www.cancermusic.org/iframe.htm
is there anyway of the iframe only coming into use if one of the external links is used. What I mean is that the page can have all info on it that I have put there (normal html page no frames), and then when an external link is clicked the iframe would only pop in then, and then an internal link may be clicked again and the page does not have the space where the iframe was.

Thanks again.

Nat

Last edited by sparkiii; 03-26-07 at 07:19 AM. Reason: adding more info
Reply With Quote
  #7 (permalink)  
Old 03-27-07, 02:32 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
They are doing the same thing here "http://www.cancermusic.org". They have their buttons on the side instead of the top. And the IFRAME works better than require("somepage.com") for your purpose. I find that the require() command works well if you are designing all of your own pages. That way there are no conflicts with your main page.
Example:
PHP Code:

<?php
$next_page 
$_POST["page_no"];  // Note: "page_no" is the name of a hidden input in the form.
if(!$next_page){$next_page 1;}

echo(
"<table rules=\"all\" style=\"width:100%;border:solid 1 #000000;\">");
echo(
"<tr>");
echo(
"<td width=\"40%\"></td>");
echo(
"<td>");
echo(
"<form name=\"theform\" action=\"#\" method=\"POST\">");
echo(
"<input id=\"p_no\" type=\"hidden\" name=\"page_no\" value=\"1\">");
echo(
"<input type=\"submit\" value=\"Page 1\">");
echo(
"</form>");
echo(
"</td>");
echo(
"<td>");
echo(
"<form name=\"theform\" action=\"#\" method=\"POST\">");
echo(
"<input id=\"p_no\" type=\"hidden\" name=\"page_no\" value=\"2\">");
echo(
"<input type=\"submit\" value=\"Page 2\">");
echo(
"</form>");
echo(
"</td>");
echo(
"<td>");
echo(
"<form name=\"theform\" action=\"#\" method=\"POST\">");
echo(
"<input id=\"p_no\" type=\"hidden\" name=\"page_no\" value=\"3\">");
echo(
"<input type=\"submit\" value=\"Page 3\">");
echo(
"</form>");
echo(
"</td>");
echo(
"<td width=\"40%\"></td>");
echo(
"</tr>");
echo(
"<tr>");
if(
$next_page == 1)
{
 echo(
"<td colspan=\"5\">");
 echo(
"<IFRAME src=\"http://www.in2media.com.au\" width=\"100%\" height=\"500\"
             scrolling=\"auto\" frameborder=\"1\">
  [Your user agent does not support frames or is currently configured
  not to display frames. However, you may visit
  <A href=\"http://www.in2media.com.au\">the related document.</A>]
  </IFRAME>"
);
 echo(
"</td>");
 }
if(
$next_page == 2)
{
 echo(
"<td colspan=\"5\">");
 echo(
"This is page 2. Put something else here.");
 require(
"page_2.php");
 echo(
"</td>");
 }
if(
$next_page == 3)
{
 echo(
"<td colspan=\"5\">");
 echo(
"This is page 3. This is the last page for this demo.");
 require(
"page_3.php");
 echo(
"</td>");
 }
echo(
"</tr>");
echo(
"</table>");
?>
__________________
Jerry Broughton

Last edited by job0107; 03-27-07 at 02:43 AM.
Reply With Quote
  #8 (permalink)  
Old 03-27-07, 03:15 AM
job0107's Avatar
job0107 job0107 is offline
Community Liaison
 
Join Date: Dec 2006
Location: Tacoma, Washington USA
Posts: 3,454
Thanks: 0
Thanked 140 Times in 137 Posts
Here is an example with the buttons on the side.
It could be a lot easier to position things on the screen
if you used <div>'s and <span>'s instead of a table.
As you can see there are several ways to get the job done.
PHP Code:

<?php
$next_page 
$_POST["submit"];
if(!
$next_page){$next_page "IN2MEDIA";}

echo(
"<table rules=\"all\" style=\"width:100%;border:solid 1 #000000;\">");
echo(
"<tr>");
echo(
"<td rowspan=\"3\">");
if(
$next_page == "IN2MEDIA")
{
 echo(
"<IFRAME src=\"http://www.in2media.com.au\" width=\"100%\" height=\"500\"
             scrolling=\"auto\" frameborder=\"1\">
  [Your user agent does not support frames or is currently configured
  not to display frames. However, you may visit
  <A href=\"http://www.in2media.com.au\">the related document.</A>]
  </IFRAME>"
);
 }
if(
$next_page == "MSN")
{
 echo(
"<IFRAME src=\"http://www.msn.com\" width=\"100%\" height=\"500\"
             scrolling=\"auto\" frameborder=\"1\">
  [Your user agent does not support frames or is currently configured
  not to display frames. However, you may visit
  <A href=\"http://www.msn.com\">the related document.</A>]
  </IFRAME>"
);
 }
if(
$next_page == "GOOGLE")
{
 echo(
"<IFRAME src=\"http://www.google.com\" width=\"100%\" height=\"500\"
             scrolling=\"auto\" frameborder=\"1\">
  [Your user agent does not support frames or is currently configured
  not to display frames. However, you may visit
  <A href=\"http://www.google.com\">the related document.</A>]
  </IFRAME>"
);
 }
echo(
"</td>");
echo(
"<td align=\"center\">");
echo(
"<form action=\"#\" method=\"POST\">");
echo(
"<input name=\"submit\" type=\"submit\" value=\"IN2MEDIA\">");
echo(
"</form>");
echo(
"</td>");
echo(
"</tr>");

echo(
"<tr>");
echo(
"<td align=\"center\">");
echo(
"<form action=\"#\" method=\"POST\">");
echo(
"<input name=\"submit\" type=\"submit\" value=\"MSN\">");
echo(
"</form>");
echo(
"</td>");
echo(
"</tr>");

echo(
"<tr>");
echo(
"<td align=\"center\">");
echo(
"<form action=\"#\" method=\"POST\">");
echo(
"<input name=\"submit\" type=\"submit\" value=\"GOOGLE\">");
echo(
"</form>");
echo(
"</td>");
echo(
"</tr>");
echo(
"</table>");
?>
__________________
Jerry Broughton

Last edited by job0107; 03-27-07 at 03:42 AM.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[turnkey] Lyrics site - $149 (LEGAL) rightinpoint General Advertisements 0 10-22-06 04:33 AM
Classified Ads skipper23 Perl 3 11-22-05 02:22 AM
Xml / Dom / Css Mark_SC.SE JavaScript 0 06-29-05 08:05 AM
Link to external page in PHP/MYSQL truesilentassassin PHP 5 07-22-04 08:48 PM
Classified Ads skipper23 Perl 2 12-30-03 03:43 AM


All times are GMT -5. The time now is 11:34 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.