Great menu system
Im curious about the best way to deal with using advanced javascript functions, such as a popup window for example called via the menu.
This is the code to our chatroom. When a user clicks the chat button it calls a javascript routine that calculates the users screen resolution then pops a centered window and loads the chatroom in it.
Code: Select all
<a href="/chat/login.php" onclick="chatroom(this.href,'chat','620','540','yes','center');return false" onfocus="this.blur()">Chatroom</a>
Code: Select all
<script language="javascript" type="text/javascript">
var win=null;
function chatroom(mypage,myname,w,h,scroll,pos){
if(pos=="random"){LeftPosition=(screen.width)?Math.floor(Math.random()*(screen.width-w)):100;TopPosition=(screen.height)?Math.floor(Math.random()*((screen.height-h)-95)):100;}
if(pos=="center"){LeftPosition=(screen.width)?(screen.width-w)/2:100;TopPosition=(screen.height)?(screen.height-h)/2:100;}
else if((pos!="center" && pos!="random") || pos==null){LeftPosition=0;TopPosition=0}
settings='width='+w+',height='+h+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,location=no,directories=no,status=yes,menubar=no,toolbar=no,resizable=yes';
win=window.open(mypage,myname,settings);}
</script>
I tried to add the function call as a menu item but it didnt work, any idea where I went wrong?
Code: Select all
aI("text=Chatroom;url=chat/login.php" onclick="chatroom(this.href,'chat','620','540','yes','center');return false" onfocus="this.blur()">Chatroom");
------------------
Deep thought...
------------------
What if I wanted to add a javascript menu item down the road? well okay so I add the menu item that calls the function, thats fine, but where do I put the function itself? I cant imagine that I need to add it to every single page, that would be a nightmare, we have over 300 pages and some are dynamically created, so if can we grab it when the menu loads, instead of when the page loads? This would be idea since the menu is shared with all pages.
Well If I can have some thoughts, on this please and thank you
Rob