window.open alternative?

D

Dave

I have a button on a nested master.page that opens a popup titled
OnlineHelp.aspx with window.open. It works fine as long as I stay in
the root of my site. When I navigate to a page in another folder it
thinks that the OnlineHelp page is in the root of that folder...and it
gets lost. Below is the code that I'm using...

StringBuilder sb = new StringBuilder();
sb.Append("<script>");
sb.Append("window.open('Documentation/OnlineHelp.aspx',
'','menubar=0,toolbar=0,height=475,width=435,resizable=1,scrollbars=1,
Left=50, top=120');");
sb.Append("</script>");


is there another way to identify the path?

Or is there a more prefered way to do this?

Thanks for your help.
 
D

Dave

Thanks for the quick reply Mark!

In your comment about replacing sb.Append("<script>") with sb.Append
("<script type=\"text/javascript\">"); ....what would be the closing
tag for something like this?

Thanks
 
G

Göran Andersson

Dave said:
Thanks for the quick reply Mark!

In your comment about replacing sb.Append("<script>") with sb.Append
("<script type=\"text/javascript\">"); ....what would be the closing
tag for something like this?

</script>
 
G

Göran Andersson

Dave said:
I have a button on a nested master.page that opens a popup titled
OnlineHelp.aspx with window.open. It works fine as long as I stay in
the root of my site. When I navigate to a page in another folder it
thinks that the OnlineHelp page is in the root of that folder...and it
gets lost. Below is the code that I'm using...

StringBuilder sb = new StringBuilder();
sb.Append("<script>");
sb.Append("window.open('Documentation/OnlineHelp.aspx',
'','menubar=0,toolbar=0,height=475,width=435,resizable=1,scrollbars=1,
Left=50, top=120');");
sb.Append("</script>");


is there another way to identify the path?

Or is there a more prefered way to do this?

Thanks for your help.

Specify the url from the web root, and use the ResolveUrl method to get
an url that the client can use:

string url = Page.ResolveUrl("~/Documentation/OnlineHelp.aspx");
string code =
"<script type=\"text/javascript\">" +
"window.open('" + url +
"','_blank','menubar=0,toolbar=0,height=475,width=435,resizable=1,scrollbars=1,left=50,
top=120');" +
"</script>");

There isn't really any use for a StringBuilder when concatenating
something simple as this.

Use "_blank" for window name if you want to open a new window. Leaving
it empty may have unpredicted effects.
 

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

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top