|
-
Aug 1st, 2005, 10:45 PM
#1
Thread Starter
Frenzied Member
Javascript Open Window
I am using Javascript to open a URL in a new window. It works fine except that the calling window refreshes and moves back to the top of the page.
How do I make sure that the calling page stays in the same position?
-
Aug 1st, 2005, 10:56 PM
#2
Lively Member
Re: Javascript Open Window
Hi,
Can u please paste the code .
It will help to understand.
Regards
-Sachien
-
Aug 1st, 2005, 11:40 PM
#3
Thread Starter
Frenzied Member
Re: Javascript Open Window
VB Code:
Private Sub JavaScriptOpenWindow(ByRef sURL As String, Optional ByRef sHeight As String = "768", Optional ByRef sWidth As String = "1024", Optional ByRef sToolbar As String = "0", _
Optional ByRef sScrollBars As String = "0", Optional ByRef sLocation As String = "0", Optional ByRef sStatusBar As String = "0", _
Optional ByRef sMenuBar As String = "0", Optional ByRef sResizable As String = "0", _
Optional ByRef sLeft As String = "0", Optional ByRef sRight As String = "0")
Dim sWindowRef As String = GenRandom()
Dim sJavaScript As String = "<script language=javascript>window.open('" & sURL & "','" & sWindowRef & "', 'toolbar=" & sToolbar & ",scrollbars=" & sScrollBars & ",location=" & sLocation & ",statusbar=" & sStatusBar & ",menubar=" & sMenuBar & ",resizable=" & sResizable & ",left=" & sLeft & ",right=" & sRight & ",width=" & sWidth & ",height=" & sHeight & "');</script>"
Response.Write(sJavaScript)
Response.Flush()
End Sub
The function GenRandom returns a random string which uniquely identifies the new window so that subsequent calls open another new window.
-
Aug 1st, 2005, 11:47 PM
#4
Re: Javascript Open Window
What events on the page make you call a this subroutine? Is it being called from a link?
-
Aug 1st, 2005, 11:51 PM
#5
Thread Starter
Frenzied Member
Re: Javascript Open Window
I am calling it from a DataGrid1_ItemCommand routine in response to clicking on a link button column in the grid.
-
Aug 2nd, 2005, 12:26 AM
#6
Re: Javascript Open Window
Perhaps you should be setting the navigateurl for your hyperlinks in the itemdatabound event, surely there is some logic to the sURL you generate? Simply make it call a predefined javascript function which already exists in your ASPX code instead of going through this hassle.
-
Sep 13th, 2005, 10:45 PM
#7
Thread Starter
Frenzied Member
Re: Javascript Open Window
If I can find a way around this with my current code, it would be better because it works exactly the way I want it to except for the refresh problem.
Is there some way that I can create an anchor at the row on the grid that the user clicked on to open the new window? I could store the row number in either a hidden label or in a session variable and have a button at the top of the page called "Go To Last Position" which when clicked on would go the row that was clicked previously. This would do the job for me.
-
Nov 26th, 2005, 05:47 PM
#8
Frenzied Member
Re: Javascript Open Window
Great Code Robertx , you have gained my rating for this
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|