views:

22

answers:

2

Hello everyone, i am currently working on a website and I need to make a chat application for it (as seen on some other questions i posted, haha)

Anyway, the gist is that I now have my website (on localhost for the time being), and my chat application. Now i need to make a button which, on click, will open the chat webpage in a pop-up window. I can do this easily with the following code:

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JavaScript">
function AlertCC()
{
window.open("http://localhost/chat/node/1", "MyWindow", "height=520,width=560,scrollbars=no"); 
}
</SCRIPT>
</HEAD>
<BODY>
<CENTER><FORM><INPUT TYPE="BUTTON" VALUE="Open Chat Room" onClick="AlertCC()"></FORM></CENTER><p>

My problem is in the part of the:

window.open("http://localhost/chat/node/1", "MyWindow", "height=520,width=560,scrollbars=no");

wherein when I click the button, the page http://localhost/chat/node/1 will be opened in a pop-up window. This works well IN MY MACHINE with my localhost. However, whenever I run this on some other computer on the network through localhost, it opens the pop-up window (as expected) and does not navigate to the url. Based on some investigations I did, it basically looks for the native localhost (the localhost of the computer) and not into my localhost where the core files are located. I have options of changing my pop-up window opener code but I can't seem to find any other options than this one.

Can anybody please tell me how I will be able to fix this? Thanks a lot :)

+1  A: 

If you want to let others test on your machine, you need to either change the link, so it points to your machine (IP), or use the vhost file on their machines to let localhost point to your machine.

Debugging these kinds of problems, is best done on a dev / staging server though.

googletorp
Or, I'll add, maybe just use a relative link - I'm not sure why that wouldn't work, *if they are already accessing the webserver where your application resides*.
altCognito
yes, this is exactly what I need. i need it to point to my own localhost machine, however, I can't seem to make it work. I've tried changing the link into ../themes/garland/page-node-1.tpl.phpbut it can't read it which lead me to an assumption that maybe window.open method is just used to open webpages and not web server files.
Kim
A: 

Why not just

window.open("http://www.domain.com/chat/node/1"

On your machine, make a hosts file entry for www.domain.com with your IP (or server environment IP) on your network. Should work.

Kevin
i'm sorry, i'm quite a newbie so i don't understand these stuffs. can you please elaborate further on how to do this? steps possibly? thanks a lot :)
Kim