2 Replies - 3463 Views - Last Post: 16 July 2012 - 05:54 AM

#1 X-spert  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 56
  • Joined: 25-August 11

Task - Open a window without menu bar

Posted 12 July 2012 - 05:45 AM

Hello,

I need to disable the browser menu bar for a web page and, from what I read, I need open this page in a pop-up page using "window.open..." and disable the menubar for this one.

The problem is that I do this on document ready and the "window.open..." statement will loop to infinite and will open "infinite" pages.

Here is a sample:
<script language="javascript" type="text/javascript">
		$(document).ready(function() {								
			popupWindow(document.URL);							
			
			$('body').attr('oncontextmenu','return false;');			
			
			$('a').click(function(event) { 
				if (isCtrlKeyPressed(event.type)) {
					event.preventDefault();
				}
			});									
		});	
		
		function popupWindow(url) {					
			var newwindow;
			newwindow = window.open(url, window.name, 'directories = no, toolbar = no, menubar = no, resizable = no, scrollbars = no, status = no, width=' + screen.width + ', height=' + screen.height + '');
			newwindow.moveTo(0, 0);
			if (window.focus) {newwindow.focus()}					
		}
		
		function isCtrlKeyPressed(evt) {
			var ctrlMod = (window.event)? window.event.ctrlKey : evt.ctrlKey;
			return ctrlMod;
		};
		</script>



I need an idea to control this... open just one page...
Maybe if I put an "if" for the pop-up page to check if the pop-up page already have menubar disabled this will do?!

Thanks in advance!

This post has been edited by X-spert: 12 July 2012 - 05:51 AM


Is This A Good Question/Topic? 0
  • +

Replies To: Task - Open a window without menu bar

#2 exiles.prx  Icon User is offline

  • D.I.C Head

Reputation: 65
  • View blog
  • Posts: 239
  • Joined: 22-November 10

Re: Task - Open a window without menu bar

Posted 15 July 2012 - 06:22 PM

Your getting infinite pages opening because you are opening the same URL on every window.open call which contains the java script file to open up another window with the same URL which opens up a window with the java script file to open up another window... and so on, and so on. You need to open a new window on a timed event using a function such as setTimeout() and not in the document ready function.

This post has been edited by exiles.prx: 15 July 2012 - 06:22 PM

Was This Post Helpful? 0
  • +
  • -

#3 X-spert  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 56
  • Joined: 25-August 11

Re: Task - Open a window without menu bar

Posted 16 July 2012 - 05:54 AM

View Postexiles.prx, on 15 July 2012 - 06:22 PM, said:

Your getting infinite pages opening because you are opening the same URL on every window.open call which contains the java script file to open up another window with the same URL which opens up a window with the java script file to open up another window... and so on, and so on. You need to open a new window on a timed event using a function such as setTimeout() and not in the document ready function.


Thank you man...
I know that... may be I don't asked the right question...
After few hours I successfully resolve the problem.

Thank you again!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1