Solved

About JavaScript

Posted on 1998-06-25
8
172 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
Comment Utility
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
Comment Utility
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
Comment Utility
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 6

Expert Comment

by:Holger101497
Comment Utility
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
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 1

Author Comment

by:aacosta
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Thanks!, it`s working
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
HTML 5 video and audio or Flash 1 29
Setting Up a Responsive Form 24 41
FTP File permissions 1 28
C3-->D3 Line Chart 4 17
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
In this tutorial viewers will learn how to define a gradient in CSS. Create a new HTML document with an internal stylesheet.: Create a div in CSS and name it Gradient. Define the background as "linear-gradient(to right, #ee3668, black)". Ensure you …
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now