How do I spawn a new IE window with no toolbar?

V

VB Programmer

On some websites I've seen by clicking on a button or hlink a new IE browser
window is spawned that does NOT have any toolbar (ie No back button, etc...)

How can I do this on my ASPX page?

Thanks.
 
M

Mark

JavaScript. Find a site that has that functionality you like and view the
source of the page. Copy and paste into your code. Since it is JavaScript
it will be viewable in the source unlike VB.NET or C# code that would
otherwise be compiled into IL.

Good luck.

Mark
 
M

Mark

Below is an example that will get you started ... it spawns the new window,
but includes a toolbar.

//JavaScript that opens a hyperlink in a new browser window.
StringBuilder sb = new StringBuilder();
sb.Append("<script language=\"javascript\">" + Environment.NewLine);
sb.Append("<!--"+ Environment.NewLine);
sb.Append("function popup(mylink, windowname)"+ Environment.NewLine);
sb.Append("{"+ Environment.NewLine);
sb.Append("if (! window.focus)return true;"+ Environment.NewLine);
sb.Append("var href;"+ Environment.NewLine);
sb.Append("if (typeof(mylink) == 'string')"+ Environment.NewLine);
sb.Append("href=mylink;"+ Environment.NewLine);
sb.Append("else"+ Environment.NewLine);
sb.Append("href=mylink.href;"+ Environment.NewLine);
sb.Append("window.open(href,
windowname,'width=700,height=400,scrollbars=yes,status=yes,menubar=yes,locat
ion=yes,toolbar=yes');"+ Environment.NewLine);
sb.Append("return false;"+ Environment.NewLine);
sb.Append("}"+ Environment.NewLine);
sb.Append("//-->"+ Environment.NewLine);
sb.Append("</script>"+ Environment.NewLine);
LiteralControl lc = new LiteralControl(sb.ToString());
this.Controls.Add(lc);

hth, mark
www.dovetaildatabases.com
 
A

Alvin Bruney

window.open () function accepts a toolbar and menubar parameter you can set
these to no
 
S

S. Justin Gengo

VBProgrammer,

If you want, I created a Javascript component that has a few commonly used
javascripts in it that makes it easy to attach them to a page and then any
object on the page. A popup window with options for exactly what parts to
display is one of the functions. I provide it for free and the entire
project is downloadable from my web site, www.aboutfortunate.com. Just
click the code library link and then click the "Javascript" button in the
menu on the left.

Sincerely,

--
S. Justin Gengo, MCP
Web Developer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
 
B

Brian W

No offence, but how about something a little more elegant, readable, and a
bit faster, and doesnt require the use ot a Literal

Add the following to your Page_Load (you can even make the the string a
static readonly field on your page class)

string popupScript =
@"<script language=""javascript"">
<!--
function popup(mylink, windowname) {
if (! window.focus)return true;
var href;
if (typeof(mylink) == 'string')
href=mylink;
else
href=mylink.href;
window.open(href,
windowname,'width=700,height=400,scrollbars=yes,status=yes,menubar=yes,locat
ion=yes,toolbar=yes');
return false;
}
//-->
</script>";
RegisterClientScriptBlock("popup" , s);


Or place the script in a separate file (ie popup.js) and add the following
to the top of your page:

<script language="javascript" src="popup.js" >

HTH
Brian W
 
M

Mark

I'd agree that in most cases that would be faster and more elegant. The
code I copied from was in the
protected override void CreateChildControls()

event of a custom control. In custom controls, you can't paste in raw
script like you can in a .aspx or user control.

Mark
 
B

Brian W

event of a custom control. In custom controls, you can't paste in raw
script like you can in a .aspx or user control.

Sure you can. That is what Page.RegisterClientScriptBlock() is for.

Brian W
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top