Solved

About JavaScript

Posted on 1998-06-25
8
175 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
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
HTML5 frame 5 30
Writing comments on <p></P> or paragraph 2 19
How easy is it to support multiple logins to my website on one web browser session? 5 35
Html value of radio 14 27
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
This article discusses four methods for overlaying images in a container on a web page
In this tutorial viewers will learn how to embed videos in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <video> tag to insert a video. Define the src as the URL of your video; this is similar to …
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

808 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