Wow Web Designs Forums Home

Search
   
Members

Calendar

Help

Home
Search by username
Not logged in - Login | Register 
Wow Web Designs Forums > Scripting > HTML & CSS > Open New Page In Certain Size


Open New Page In Certain Size
 Moderated by: Aycan  

New Topic

Reply

Print
AuthorPost
GenoBaby
Member


Joined: Fri Nov 1st, 2002
Location: Brooklyn, New York USA
Posts: 38
Status:  Offline
Mana: 
 Posted: Mon Mar 6th, 2006 07:43 pm

Quote

Reply
It's possible... one way of doing it is to create an HTML page that will contain the codes to change the background color or any other attributes that you want to make dynamic even if it's not part of the window function... and the link that actually opens the pop up window can add extra query strings to the end of the URL to create this effect... let me elaborate with examples because just writing an explanation may not be clear. I'm going to write the code you will use for the links and the code that would be on the other window itself and then explain what each line of code means.

Example.
On the page that will contain the link to open the new window add this function inside of the HEAD section of your HTML document:

function openWin( bgc ) {
    window.open( "popup.htm?" + bgc, "", "height=500,width=500");
}


The link that opens the window should look something like this:

<a href="javascript:openWin( 'yellow' )">Click Here</a>

Create another HTML page and name it popup.htm and add this line of code to its HEAD section:

var arg    = self.location.href.split( "?" );
var bgc    = arg[1];

function changeBG(){
    document.bgColor = bgc;
}


and then add an onload attribute to the body tag to fire the function... like this:

<body onload="changeBG()">

Now here's how everything works and I hope this can be a starting point for everything you want to do in the new window.

The page with the link has a function with only one parameter 'bgc' (it can have more... i just did one for this example). BGC is just short for Back Ground Color. The link triggers that functions and sends the value of 'yellow'.  The function opens up the page popup.htm and it adds the query string yellow to the end of it so it's really opening up the page popup.htm?yellow.

Now on the popup.htm page I created a variable called arg (it's just short for argument) and gave it the value of self.location.href.split("?"). What that line of code does is takes the current URL of that page... which is popup.htm?yellow... looks for a question mark... and then splits it everytime it finds a question mark. It takes each value after the split and puts it in an array. arg[0] would be what's before the question mark and yellow would be in arg[1].

I created another variable called bgc and added what ever the value of arg[1] is which is yellow.

Once the page loads it fires the function changeBG()

The changeBG function changes the documents background color to whatever the value of bgc is... which is yellow.

Now i hope this gives a general idea of how to pass other information to the new window... also note that i made the window open at 500 pixels in width and height. You don't need that if you just want to open up a window without size restrictions. Also there's a bunch of error trapping that should be added but i didn't do so so that the code doesn't look too confusing at first glance. Let me know if this helps out in any way.


TomWhitney
Member


Joined: Fri Dec 30th, 2005
Location: Phoenix, Arizona USA
Posts: 102
Status:  Offline
Mana: 
 Posted: Mon Mar 6th, 2006 08:09 pm

Quote

Reply
Urobos,

What are you putting in the popup windows? Are there things in common between the 70+ windows? Do you have an example?


Urobos
Member


Joined: Mon Mar 6th, 2006
Location: USA
Posts: 2
Status:  Offline
Mana: 
 Posted: Mon Mar 6th, 2006 08:51 pm

Quote

Reply
Zoinks - Thanks for the pointers GenoBaby. I am still wading through your response but it seems to make sense. I will try to implement this solution. Thanks, dude.

Tom Whitney - If you go to http://www.gargantuanmedia.com/illustrations.htm you can see that I've got some pop-ups that work - they just are really dull.
Rockstargames had a really cool Pop-Up window style a few years back that I am trying to re-create.

mintylouse
Member
 

Joined: Wed Nov 28th, 2007
Location:  
Posts: 1
Status:  Offline
Mana: 
 Posted: Wed Nov 28th, 2007 02:34 pm

Quote

Reply
this has been a major help but i do have 1 quesiton.

what if i wanted to open Thumbnailed pictures to open in a new window.

Each thumbnails opens up a diffrent page such as

thumb1.html, thumb2.html , thumb3.html

If i use the code

<script LANGUAGE="JavaScript">
function openWindowCentered(){
window.open('thumb1.html', 'newwin', 'width=500, height=400, left='+(screen.width-500)/2+', top='+(screen.height-300)/2+', resizable=no, scrollbars=no, toolbars=no, location=no, directories=no, status=no, menubar=no, copyhistory=no');
}

</script>

 

And ahref link it to a picture it will work but how do i link the next picture to open up with the same options ? i cannot make a seperate code again but instead of thumb1 name it thumb2 =(

HELPP!

TomWhitney
Member


Joined: Fri Dec 30th, 2005
Location: Phoenix, Arizona USA
Posts: 102
Status:  Offline
Mana: 
 Posted: Wed Nov 28th, 2007 03:10 pm

Quote

Reply
Hopefully I understand the question. Try passing the url into the function.

<script LANGUAGE="JavaScript">
function openWindowCentered(url)
{
window.open(url,'newwin', 'width=500, height=400, left='+(screen.width-500)/2+', top='+(screen.height-300)/2+', resizable=no, scrollbars=no, toolbars=no, location=no, directories=no, status=no, menubar=no, copyhistory=no');
}
</script>


Call it with

<a href="thumb1.html" onclick="openWindowCentered(this.href); return(false)">
   <img src="img1.jpg"/></a>
<a href="thumb2.html" onclick="openWindowCentered(this.href); return(false)">
   <img src="img2.jpg"/></a>


I code it this way because it will still work for viewers without JavaScript.

Tom Whitney - SharkZone Design
Phoenix Arizona Computer Consultant

resource004
Member
 

Joined: Fri Apr 4th, 2008
Location:  
Posts: 63
Status:  Offline
Mana: 
 Posted: Thu Apr 24th, 2008 07:25 am

Quote

Reply
Hi Friends,
Do you have any problem in web designing and development or do you want any kind of help in PHP/MYSQL or you need reliable and cheap web hosting or have any problem in E-commerce solutions then go to this site http://www.pakandu.com/contactus.php ,
It is a company of web designing and development and it have a great web designers, developers and Programmers.
When I got in any problem of web designing /development and Programming  or I need reliable web hosting or facing any problem in E-commerce Solutions then I just go to this site and ask them the solution of my problem and they always provide me best solution for my problem.
So do you have any above problems then contact them without any hesitation.
 
Regards,
 
Resource


 Current time is 02:04 am
Page:  First Page Previous Page  1  2   




Powered by WowBB 1.7 - Copyright © 2003-2006 Aycan Gulez
Page processed in 0.1690 seconds (16% database + 84% PHP). 16 queries executed.