Hello people. I have a pop up window and i have 2 pages that open the same pop up window.

I want to make a button hidden when one specific page opens my pop up. If the other page opens my window; i want the button to be there and not to be hidden.


Also how can i learn which page opened my popup in the js file of the popup?

Like the relative path of the opener.

I know things will be easier if i can know the path so i can hide or unhide the button just with an if block.

Any suggestions please?

Xessa,

This is very simple, though maybe not obvious.

First create a funtion in your main page

function popUpCallback(x){
	var b = document.getElementById('b1');//the button that you want to hide/show
	if(b) { b.style.display = (x) ? 'inline' : 'none'; }
	//Add/modify this function to do whatever you want in the main page.
}

Then, in each of the popup pages that you want to suppress your button:

onload = function(){
	opener.popUpCallback(0);
}
onunload = function(){
	opener.popUpCallback(1);
}

Here, I just pass back binary 0|1 but you could pass anything you like to the the main page and test/act accordingly in popUpCallback.

This scheme will still work if another page is served into the main window, as long as it (a) is from the same domain and (b) contains the popUpCallback fn.

Tested in IE6 and FF 3.0.12

Hope this helps

Airshow

Comments
thank you. i will try this tomorrow

I think you will get the reference to the parent window using script like

<script type="text/javascript">
function openWin()
{
        myWindow=window.open('<url>','<name>','<properties>');      //it will giv U a child window
        parent_obj=[B]myWindow.opener[/B];        // This one will give you the ref. to the parent window
}
</script>

All the best dear friend....

with thanks regards
Krishnan

This question has already been answered. Start a new discussion instead.