Solved

About JavaScript

Posted on 1998-06-25
8
176 Views
Last Modified: 2010-04-09
I have this function:

<script language="JavaScript">
<!--
function OpenWindow() {

pagina="home.html";
var wnd="four11Kiosk";
var pagina="home.html"
var width='430';
var height='300';
var loc="/scripts/ale/pendientes.idc";
var myWindow = window.open(loc,

wnd,"resizable=yes,scrollbars=yes,width="+width+",height="+height);
return pagina;

}
-->
</script>

and I am calling it troughtout this command:

<a href="javascript:OpenWindow()"; return true;>Consultar TT</a>

So, I want to open a new browser in my client with a new page and open a new page in my original browser, how can I do it.

Thanks.

0
Comment
Question by:aacosta
8 Comments
 

Expert Comment

by:fshakir
ID: 1844392
Save yourself some javascript trouble.  Here is a smaller, easier to understand version:

in the home.html page, paste this in:

<body onload="window.open(/scripts/ale/pendientes.idc, four11Kiosk, resizable=yes, scrollbars=yes, width=430, height=300)"
</body>

0
 
LVL 1

Author Comment

by:aacosta
ID: 1844393
Yor are right, but at the time my browser is opening the page home.html it does does not finish loading the page, why?, the browser only open me a new browser with pendientes.idc

Thanks.
0
 
LVL 1

Author Comment

by:aacosta
ID: 1844394
Yor are right, but at the time my browser is opening the page home.html it does does not finish loading the page, why?, the browser only open me a new browser with pendientes.idc

Thanks.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:Holger101497
ID: 1844395
Could you be more specific about waht the "original problem" was? Which part didn't work?
The "return true" seems strange... is it in any handler like onclick? Or just in the HTML code... the way you posted it, it won't work correctly...

You said: "and open a new page in my original browser"...
Where do you do that??`You need to call document.location.href='newpageformainwindow.html' as well...

IF you want "href='JavaScript:OpenWindow()'" to point to home.html, because that's the value your function returns, I have to disappoint you. You cannot use JavaScript-values that easily

Try this: <a href=&{OpenWindow()};>Consultar TT</a>
or this: <a href='home.html' onclick='OpenWindow()'>

Actually, the second way is better because it will work in nearly all brwosers - the first one is will only work in Netscape.

Let me know if that helped...
0
 
LVL 1

Author Comment

by:aacosta
ID: 1844396
Hello, thanks for your tips. Your are right, I used the second way and it worked!, Thanks, but I have another question, if you like answer me it and I will graded you :-).

After I open my windows with java script, can I close it from my original window? I mean:
I have windows1, it open a new windows2 (I have boths opened), can I close windows2 from windows1 with and event botton?.

Thanks.
0
 
LVL 5

Expert Comment

by:Christian_Wenz
ID: 1844397
just a little correction to fshakir's rejected answer:

<body onload="window.open('/scripts/ale/pendientes.idc', 'four11Kiosk', 'resizable=yes,scrollbars=yes,width=430,height=300')"
</body>
0
 
LVL 6

Accepted Solution

by:
Holger101497 earned 150 total points
ID: 1844398
To close a window (can only be done if it was opened by JavaScript (or has only displayed one page so far)), you can just call windowreference.close().

This is just a little example (quickly done... no error checking (e.g. if the window is still open...)). Let me know if you need to know more...

<HTML>  <HEAD>
  <TITLE> </TITLE>

  <script language="JavaScript">
  <!--
  function wo() {ws=window.open('test.htm','MyWin','height=300,width=400');ws.focus(); //open and bring to front if open already
}

  function wc() {if (ws) ws.close();}    
  // -->
  </script>

</HEAD>
<BODY>
<a href='javaScript:wo()'>Open new window</a>
<a href='javaScript:wc()'>Close it</a>
</BODY>

</HTML>

Let me know if you have more questions...

Good luck,
Holger
0
 
LVL 1

Author Comment

by:aacosta
ID: 1844399
Thanks!, it`s working
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question