Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Window Open Order

Status
Not open for further replies.

lakeside12

Programmer
Apr 20, 2009
43
CA
Hi,

I have a question on window open events

I have an event that calls a function on a mouse event and it works fine

The function is this

function SureTab()
{
window.open('MyURL?zip=<%=request.querystring("Zip") %>')
}
</script>


I have 2 problems, first I was trying to pass in the value of a field, but did not know how, so I used ASP code and that did not work either. How do I do that in Javascrip?

Second question, this windows when it opens takes control from the previous window. Is it possible to open a window and not have it the dominant window. In this case in tests it opens 99% of times as a browser TAB which is perfect, but I do not want control passed to it, I want to stay on the current window. How do I do that?

Many thanks for your help
 
for your first question you can use either of the following approaches :


if you can provide the source of your form we should be able to provide a working sample for you.

As for your second question, a quick search - - yeilds several posts on the subject.

Greg Griffiths
Livelink Certified Developer & ECM Global Star Champion 2005 & 2006
 
ok many thanks for your reply which I appreciate!

Using your example I have created a form field Zip now with an ID and I have given it an id=zipcode

This is my new version

function SureTab()
{
window.open('MyURL?zip=<script type="text/JavaScript">
document.getElementById("zipcode")
</Script> ')
}
</script>


But it literally passes the entire getdocument by ID can you help, I know I have done something silly

Window Order:
With regards to the window opening as a TAB that is perfect, but I want the current tab the user is on to remain the focus and not switch as it currently does to the new opening tab.

if you can assist with this I would really appreciate it

Many thanks



 
Hi

What are the HTML tags doing in the middle of JavaScript code ?
Code:
[b][COLOR=blue]function[/color][/b] [b][COLOR=black]SureTab[/color][/b][COLOR=darkred]()[/color]
[COLOR=red]{[/color]                                                               
  window[COLOR=darkred].[/color][b][COLOR=black]open[/color][/b][COLOR=darkred]([/color][COLOR=red]'MyURL?zip='[/color][COLOR=darkred]+[/color]document[COLOR=darkred].[/color][b][COLOR=black]getElementById[/color][/b][COLOR=darkred]([/color][COLOR=red]"zipcode"[/color][COLOR=darkred]).[/color]value[COLOR=darkred])[/color]
[COLOR=red]}[/color]
Regarding the window focus, it is not the document's or its embedded script's business. They can not set the visitor's desktop's functionality.

Next time please post your code between [tt][ignore]
Code:
[/ignore][/tt] and [tt][ignore]
[/ignore][/tt] TGML tags.

Feherke.
 
Hi Thanks for your reply

I tried the changes, but now i do not get a tab opening up at all. Below is the exact code apart from the URL can you see any mistakes I have made

Code:
function SureTab()
{                                                               
  window.open('MyURL?zip='+document.getElementById("zipcode").value)
}

Any help is appreciated
 
feherke said:
Regarding the window focus, it is not the document's or its embedded script's business. They can not set the visitor's desktop's functionality.

Of course it is. that's why there's such a thing as the focus() method. Which works for windows as well. Though only in IE for some reason.

Just return focus to the opener window from the newly opened window. You can put this in the new windows body tag:

Code:
<body onLoad="window.opener.focus();">

Is MyURL a variable? If so, maybe doing it like this should work.

Code:
window.open(MyURL[red] + '[/red]?zip='+document.getElementById("zipcode").value)

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Hi

You are right Phil. I forgot to mention that Explorer-only solutions may exist.
Phil said:
Though only in IE for some reason.
Personally I would be very sad if my FireFox would change the browser window's focus as a stranger wants. That is a good reason for me.


Feherke.
 
Hi

Thank you for your replies, I appreciate the work you put in.

I cannot seem to have a window open with the following code, have I done somethingi ccorrect


Code:
<script type="text/javascript">

function SureTab()

 {                                                                               

	var MyURL ="[URL unfurl="true"]https://www.test.com/test.html";[/URL]

	window.open(MyURL + '?zipcode='+document.getElementById("zip").value)

 }

</script>


No Tab opens where it used to be fine before

Any ideas
many thanks
 
Please can you help me

I cannot get this to work, do I have a syntax error in this line I cannot seem to get the ZipCode

Code:
<script type="text/JavaScript">
	function sureway()

	 {
	  var myurl    = "[URL unfurl="true"]https://www.myurl.com?Zipcode="[/URL] ;
		
	  window.open(MyURL + document.getElementById("Zipcode").value)

	}
</script>

if I do not do the Document.getElement part it works fine, the moment I try and add that part in I cannot even do an Alert(msg) to see the value, so I am guessing something serious is wrong with my syntax

Many thanks
 
You originally said you gave your input an id="[blue]z[/blue]ipcode"

Using your example I have created a form field Zip now with an ID and I have given it an id=zipcode

Yet here you are attempting to use [red]Z[/red]ipcode.

Javascript is case sesnsitive, so zipcode and Zipcode are 2 different things. Make sure that they both match.

These errors are easy to pin point if you use the the browser's error displays. For IE double click on the gold shield at the bottom left corner of the window, for FF you can use its Error Console, and for Safari, you can use its Debugger.

----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.

Behind the Web, Tips and Tricks for Web Development.
 
thank you, the Z and the z can seem the same, thank you for spotting that.

Many thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top