Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
|
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 16th, 2005, 07:27 AM
Authorized User
 
Join Date: May 2004
Posts: 73
Thanks: 0
Thanked 1 Time in 1 Post
Default How to suppress address and toolbar

Hi guys,

I am working in ASP.NET. I wanna suppress address and toolbar of the browser. Of coures this can be achieved by using window.open(...) and providing appropriate parameters to it, but i need it for the EXISTING (alread rendered) page which has to be done either thru server side code or client-side using javascript where the code could run on onload even of BODY. Anybody could through light on it?



thanks



BaburMan

BaburMan
__________________
BaburMan
 
Old August 16th, 2005, 02:28 PM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

AFAIK, this cannot be done. You could open a new window and then close the original one.
Personally, I am glad this isn't possible. I really like to see the address and status bars so I can see what's going on.

Can you please not cross-post your messages? They will be read anyway...

Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old August 18th, 2005, 04:37 AM
Authorized User
 
Join Date: May 2004
Posts: 73
Thanks: 0
Thanked 1 Time in 1 Post
Default

Well, this is disappointing I have placed it in a few forums and many of them proposed the same solution as yours which i already know. Anyways thanks for that. In fact it will take more time since our page will be rendered twice this way; first in the normal window and then using js, may be in onolad event of Body, in a new window. In fact every page of the app has this requirement, so now the user will have to wait for a long time for every page which is cumbersome.



BaburMan
 
Old August 18th, 2005, 05:03 AM
Friend of Wrox
 
Join Date: May 2004
Posts: 212
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Couldn't you use a HTA instead?

Joe

 
Old August 18th, 2005, 09:31 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

It can be done for an intranet where the security settings allow unsafe ActiveX to be initialised, it doesn't have to allow downloads. The machines need to be running Windows 2000 or greater:
Code:
<html>
<head>
<title>Get Browser</title>
<meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script type="text/javascript">
/********************************************************************************************************\ 
 * Author Joe Fawcett +44 (0)770 476 089 
* 
 * Date created 2001-09-04 
* 
 * Copyright Joe Fawcett 2001 
* 
 * Version 1.0 
* 
 * You are free to use this script in an unmodified form without further 
permission.                      * 
 * This includes this comment box. Don't blame me if it goes wrong. 
* 
 * 1) Active Desktop installed, i.e. late versions of shell32.dll etc. 
plenty of info about this on web.  * 
 * 2) Security allows creation of objects and scripting etc. Therefore only 
really useful on an intranet. * 
 * 3) Er.. I hope that's it. 
* 
 * Description: The CurrentBrowser object returns a IWebBrowser2 interface 
to the running instance of IE. * 
 * This can be used to modify the current window e.g. to remove toolbars, 
close window etc.               * 
 * Returns null if unable to use Shell.Application (See above) or not found 
(Script not in browser).      * 
 * Needs to be run within a web page. 
* 
 * See below for more. 
* 


\********************************************************************************************************/ 

 var OLECMDID_PRINTPREVIEW = 7;
 
 function CurrentBrowser() 
 { 
   this.getInstance = getInstance; 


   function getInstance() 
   { 
     var oWin = null; 
     try 
     { 
       var oShellApp = new ActiveXObject("Shell.Application"); 
       colWins = oShellApp.Windows(); 
       for (var i = 0; i < colWins.Count; i++) 
       { 
         oWin = colWins(i); 
         if (oWin.document.parentWindow === self) 
         { 
           oIE = oWin; 
           return oIE; 
         } 
       } 
     } 
     catch(e) 
     { 
       alert(e.message); 
     } 
     return null; 
   } 
 } 


 //From within a web page 
 /**/
 
 function hideWindow(Seconds)
 {
   var oIE = new CurrentBrowser().getInstance(); 
   if (oIE) 
   {
     if (oIE.visible)
     {
       oIE.visible = false
       setTimeout(hideWindow, Seconds * 1000);
     }
     else
     {
       oIE.visible = true;
     }

   }   
 }
 
 function toggleToolBar() 
 { 
   var oIE = new CurrentBrowser().getInstance(); 
   if (oIE) 
   { 
     oIE.ToolBar = (!oIE.ToolBar); 
   }
   else
   {
     alert("IE not found.");
   }
   return; 
 } 

 function toggleMenuBar() 
 { 
   var oIE = new CurrentBrowser().getInstance(); 
   if (oIE) 
   { 
     oIE.MenuBar = (!oIE.MenuBar); 
   }
   else
   {
     alert("IE not found.");
   }
   return; 
 } 

 function makeResizable(Resizable)
 {
   var oIE = new CurrentBrowser().getInstance(); 
   if (oIE) 
   { 
     oIE.Resizable = Resizable; 
     return true; 
   }
   return false;   
 }
 
 function setData(DataName, DataValue) 
 { 
   var oIE = new CurrentBrowser().getInstance(); 
   if (oIE) 
   { 
     oIE.PutProperty(DataName, DataValue); 
     return true; 
   }
   return false; 
 } 


 function getData(DataName) 
 { 
   var oIE = new CurrentBrowser().getInstance(); 
   if (oIE) 
   { 
     return oIE.GetProperty(DataName); 
   }
   return null; 
 } 

 function showData(DataName)
 {
   alert(getData(DataName));
 }

 function printPreview()
 {
   var oIE = new CurrentBrowser().getInstance(); 
   if (oIE) 
   { 
     oIE.ExecWB(OLECMDID_PRINTPREVIEW, 0); 
   }
 }

</script>
</head>
<body>
<input type="button" value="Hide Window" onclick="hideWindow(txtSeconds.value);">&nbsp;for&nbsp;
<input type="text" id="txtSeconds" size="2" maxlength="2" value="5">&nbsp;seconds<br><br>
<input type="button" value="Toggle ToolBar" onclick="toggleToolBar();"><br><br>
<input type="button" value="Toggle MenuBar" onclick="toggleMenuBar();"><br><br>
<input type="button" value="Set Data" onclick="setData('data', txtData.value);">&nbsp;
<input type="text" id="txtData" size="20" value="test"><br><br>
<input type="button" value="Show Data" onclick="showData('data');"><br><br>
<label for="chkResizable">Resizable?</label><input type="checkbox" checked id="chkResizable" onclick="makeResizable(this.checked);"><br><br>
<input type="button" value="Print Preview" onclick="printPreview();"><br><br>
</body>
</html>
--

Joe (Microsoft MVP - XML)





Similar Threads
Thread Thread Starter Forum Replies Last Post
How to suppress the Outlook Address Book Securtiy bhavna General .NET 1 January 25th, 2007 12:35 PM
How to suppress address and toolbar baburman Javascript 1 August 18th, 2005 03:49 PM
Suppress report toolbar and logo dickeddy Crystal Reports 1 February 13th, 2004 05:13 AM
Retreiving IP address & gateway address sjangit VBScript 0 February 3rd, 2004 02:02 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.