hey yasmine...
no problem..
I wrote the function popUp, it accepts many parameters...
the only crutial ones that you need to supply are the first 5..
as follows:
1. the url to open in a pop up.
2. the width you want the pop up
3. the height you want the pop up
4. the location from the left of the screen in pixels
5. the location from the top of the screen in pixels.
now the rest of the parameters accept a 1 or a 0...
6. weather to show the toolbar on the pop up 1=yes 0=no
7. weather the user can resize the window 1=yes 0=no
8. weather to show scrollbars on the popup 1=yes 0=no
9. weather to show the menu bar on the popup 1=yes 0=no
10. weather to show the status bar on the popup 1=yes 0=no..
and oops!! 11 is wrong... at the end of this i will post code for that function again.. just replace with this new code.
so getting to the code...
when the function first starts executing, I am validating what was passed into the function and ensuring some default values..
like so..
Toolbar = Toolbar==null||Toolbar==""?1:Toolbar;
- this is called shorthand... it basically is an either or.
toolbar = if toolbar is null or if toolbar = "" then toolbar = 1. otherwise toolbar equals itsself - in other words dont change anything.
you could write the same thing like this...
if(toolbar==null)
{
toolbar = 1;
}else if(toolbar=="")
{
toolbar = 1;
}else
{
// dont do anything here... toolbar has a value.
}
now the next two lines have the purpose of generating an id.
this is not real necessary. but sometimes I will want to access the window i have created from another window so an id helps out.
the id is created from the time property of javascripts date object which is well the time that it is ..ie.. 12:41am.
and finally the last line in the function is where we actually create the new window. we use an eval function which is not important you are welcome to google that.. and we use the function create from the window object. which we then pass in all the parameters to tell it how to open.
the only other part of this is just using our simple function..
we can put the simple line of javascript code on any user control like the text box inside any kind of event handler like the onclick event that we used... you could put it inside an onkeydown event if you wanted to... in fact you dont have to put it in any control or handler really, you can put it anywhere that the code will execute. like just underneath the function outside of the braces of coarse..
[inside the braces would create a nasty loop opening up many pop-ups and that would be no fun] and it will pop up a window when the code executes as the page loads.
here is the revised function...
function popUp(URL,Width,Height,Left,Top,Toolbar,Resizeable ,ScrollBars,
MenuBar,StatusBar)
{
Toolbar = Toolbar==null||Toolbar==""?1:Toolbar;
Resizeable = Resizeable==null||Resizeable==""?1:Resizeable;
ScrollBars = ScrollBars==null||ScrollBars==""?1:ScrollBars;
MenuBar = MenuBar==null||MenuBar==""?1:MenuBar;
StatusBar = StatusBar==null||StatusBar==""?1:StatusBar;
day = new Date();
id = day.getTime();
eval("page" + id + " = window.open(URL, '" + id
+ "', 'toolbar="+Toolbar+",scrollbars="+ScrollBars+",loc ation=1,
statusbar="+StatusBar+",menubar="+MenuBar+",resiza ble="+
Resizeable+",width="+Width+",height="+Height+",lef t="+Left+",top="+Top+"');");
}
hope this helps ;)
-odobo
Thanks a lot odobo.
It's working.
But I can't understand the coding.
Could u plz explain about pop up messages some more.......???
Thanx n Regards
Yas.