/    Sign up×
Community /Pin to ProfileBookmark

How to open a PopUp??

hi every1

i have a simple question here, i wanna know how to open a popup but with external information, this how it is

i have about a 100 html pages numbered from 1 to 100, the main page name is index, it contains a link which opens a popup, i want the popup page to be one of the 100 pages as given, ex if the link is
index.html?page=1
the popup shows 1.html

how can i do it?
thx

to post a comment
JavaScript

8 Comments(s)

Copy linkTweet thisAlerts:
@harumphOct 05.2007 — You basically want to call index.html every time but create a popup if you also have a page=something within the address string? Can you use PHP or ASP for this process (hosting question) or are you using just HTML?
Copy linkTweet thisAlerts:
@harumphOct 05.2007 — Be aware, many people have popup blocker turned on, so they may not even realize you're creating a popup when they enter your page. I automatically leave a site if they throw a popup at me without me asking. But, here's a solution. If you're using just HTML and calling index.html from an external page, you CAN do this (ASP, PHP, etc. handle variables better & are less messy on the receiving end):

[CODE]<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title> Variable Receiver</title>

<SCRIPT LANGUAGE="JavaScript">
<!--
var page = "";
function replace(string,text,by) {
// Replaces text with by in string
var i = string.indexOf(text), newstr = '';
if ((!i) || (i == -1))
return string;
newstr += string.substring(0,i) + by;
if (i+text.length < string.length)
newstr += replace(string.substring(i+text.length,string.length),text,by);
return newstr;
}

var passed = replace(replace(location.search.substring(1),"+"," "),"=","&");

function split(string,text) {
var strLength = string.length, txtLength = text.length;
if ((strLength == 0) || (txtLength == 0)) return;
var i = string.indexOf(text);
if ((!i) && (text != string.substring(0,txtLength))) return;
if (i == -1) {
splitArray[splitIndex++] = string;
return;
}
splitArray[splitIndex++] = string.substring(0,i);
if (i+txtLength < strLength)
split(string.substring(i+txtLength,strLength),text);
return;
}

var splitIndex = 0, splitArray = new Object();

split(passed,'&');

for (var i=0; i < splitIndex; i=i+2) {
if (splitArray[i] == 'page')
page = unescape(splitArray[i+1]);
}

function OpenPopup(page){
myHandle = window.open(page + '.html','LilPopup','width=400,height=400,left=100,top=50,screenX=100,screenY=50'); //--change this to suit
if (!myHandle.opener)
myHandle.opener = self;
}
//-->
</script>

</head>

<body bgcolor="#FFFFFF">
<script language="JavaScript">
<!--
if (page != ""){
OpenPopup(page)
}
//-->
</script>
</body>
</html>[/CODE]
Copy linkTweet thisAlerts:
@SZeroauthorOct 05.2007 — harumph - it didn't work

You basically want to call index.html every time but create a popup if you also have a page=something within the address string? Can you use PHP or ASP for this process (hosting question) or are you using just HTML?[/QUOTE]

i can use php..
Copy linkTweet thisAlerts:
@harumphOct 05.2007 — What do you mean IT didn't work? Did it give you an error? The script works if you're calling index.html?page=1 from somewhere else.

(Remember "...many people have popup blocker turned on...")

If you want to use PHP, check here (get) and here (post) and remove all of my indexing crap to receive the variable data.
Copy linkTweet thisAlerts:
@LazerOct 05.2007 — Hi.

The index page should be a [B]php[/B], for this is easier to do.

in the begining of your [B]index.php[/B] add:

<?php

$pageNumber = ($_GET['page']);

$link = $pageNumber .".html" ;

?>

[B]** the ['page'] MUST be the SAME name as your passed vriable page=PageNumber **[/B]

if you want a [B]popup[/B], add in the [B]BODY[/B] of the [B]index [/B]page:

<?php print '

<script language="JavaScript">

<!-- Hide the script from old browsers --

function pop()

{window.open("' .$link. '","DummyName","menubar=0,toolbar=0,location=0,directories=0,status=0,copyhistory=0,width=800,height= 600");}

//-->

</SCRIPT>' ;

?>

To open a blank page the link in the INDEX page should look like this:

<a href="<?php echo $link; ?>" > Your text link here?</a>

To open a POPUP page the link should look like this:

<a href="dummyURL" onClick="pop(); return false;" >

Please check how it works in my web site:

http://www.elc-music.com/test/popup.php?page=1

try also page=2 no mre pages added.

Good Luck!
Copy linkTweet thisAlerts:
@harumphOct 06.2007 — If you HAVE to also generate a popup when the page loads, put his pop() function into the body tag in an onload event (although I don't advise it for reasons I mentioned earlier).
Copy linkTweet thisAlerts:
@SZeroauthorOct 06.2007 — you got me wrong guys.. i want the header info to be sent TO the popup window not the main page..

i have an Index.php with a 100 links, the pop up page is in php, it prints the info sent to it, the links in index are named for eg (pop.php?p=1) (pop.php?p=2) etc..

when i click the link, the popup shows with the (p) value printed..
Copy linkTweet thisAlerts:
@harumphOct 08.2007 — If I understand you correctly, you want to simply call pop.php and display, say, an include within pop.php of the data for "1"? Otherwise, the Lazer script is the ticket (albeit reworked a bit).
×

Success!

Help @SZero spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...