Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

open a new window with javascript

Posted on 2004-04-02
28
Medium Priority
?
930 Views
Last Modified: 2010-05-18
This is what I have to open a new window:

<%@include file="/site/includes/secure.jsp"%>
<!--%@include file="/site/includes/checklogin.jsp"%-->
<Script>
<!--
window.open('Annual_Report_c_r.pdf','','width=800,height=600,toolbar=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1');
window.history.go(-2);
//-->
</Script>

The problem is when it first open, there would be 2 pdf window open at once. The second time I open it, then it will open normally.  How can I fix this?

Thanks!
0
Comment
Question by:ericworldz
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 10
  • 8
  • 7
  • +2
28 Comments
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 10743994
what history.go(-2) is doing there!!!
0
 

Author Comment

by:ericworldz
ID: 10744060
If there's no history.back(), the first window will be showing blank. If I do history.go(-1), to go back one page, the page will keep on reload, because of the <!--%@include file="/site/includes/checklogin.jsp"%-->

So that's why I need to go back 2 pages.
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 10744084
I think that history is forcing the script to run two times........
do one thing...

<!--
window.open('Annual_Report_c_r.pdf','','width=800,height=600,toolbar=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1');
alert("test");
window.history.go(-2);
//-->
</Script>
and see how many times you see this alert.....
0
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!

 

Author Comment

by:ericworldz
ID: 10744213
yes the alert message pops up twice. so how do I fix that?
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 10744236
do not have history,back().... beacuse it will force the HTML to load from the cache and as HTML is loading it will fire up the script...

you might put some dealy on the script so that your includes load up......and then you will not need history.back()
0
 

Author Comment

by:ericworldz
ID: 10744566
can you be more specific on how this can be done without using the window.history.go(-2)? I need the first window to display the website content also without history.back(), the first window is blank.
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 10744610
<!--
window.setTimeout(500);
window.open('Annual_Report_c_r.pdf','','width=800,height=600,toolbar=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1');
//-->
</Script>


try this... it will wait for half a second before opening the pdf box.. in that much time your parent page should get loaded
0
 

Author Comment

by:ericworldz
ID: 10744683
settimeout needs 2 arguments?
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 10744692
ooops my bad...........

its gonna be

<!--
window.setTimeout("myfunc",500);
function myfunc()
{
window.open('Annual_Report_c_r.pdf','','width=800,height=600,toolbar=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1');
}
//-->
</Script>
0
 

Author Comment

by:ericworldz
ID: 10744838
The first window is still blank no matter how long the time interval is set to.
0
 
LVL 6

Expert Comment

by:jarasa
ID: 10756421

Try this:

<%@include file="/site/includes/secure.jsp"%>
<!--%@include file="/site/includes/checklogin.jsp"%-->
<Script>
<!--
var myWin = window.open('Annual_Report_c_r.pdf','','width=800,height=600,toolbar=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1');
//-->
</Script>

Javier
0
 

Author Comment

by:ericworldz
ID: 10756626
Javier,
That does exact same thing besides assigning it to the variable myWin.
0
 

Author Comment

by:ericworldz
ID: 10756634
I will have to close this question under this topic and move it to JavaScript.
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 10756829
whats written in your include files????
0
 
LVL 6

Expert Comment

by:jarasa
ID: 10757075
>That does exact same thing besides assigning it to the variable myWin.
Well normally when you assign the window.open to a var it always open the same window, that's why I told you tol test it, if it still opens you a new window maybe is becose of the includes.

Can you pos the jsp codes here?

Javier
0
 

Author Comment

by:ericworldz
ID: 10757117
<!----------------------------------checklogin.jsp-------------------------->
<%
      UID = Session("UID")
      If UID="" Then
            Response.Redirect "/site/content/login.jsp?url=" + Request.ServerVariables("SCRIPT_NAME")
      End If
%>
0
 
LVL 6

Expert Comment

by:jarasa
ID: 10757133
You picked that from and ASP??
Javier
0
 
LVL 6

Expert Comment

by:jarasa
ID: 10757167
Shouldn't it be like this:
<%
     String UID =(String)  session.getAttribute("UID")
     If (UID==null || UID.equals("")) {
          response.sendRedirect("/site/content/login.jsp?url=" + request.getHeader("SCRIPT_NAME"))
     }
%>

Javier
0
 
LVL 6

Expert Comment

by:jarasa
ID: 10757186
Sorry:

<%
     String UID =(String)  session.getAttribute("UID")
     If (UID==null || UID.equals("")) {
          response.sendRedirect("/site/content/login.jsp?url=" + request.getServletPath());
     }
%>

Javier
0
 
LVL 6

Expert Comment

by:jarasa
ID: 10757229
Anyway that shouldn't open a new window, is this all your JSP code?
0
 

Author Comment

by:ericworldz
ID: 10757643
yes
0
 
LVL 6

Expert Comment

by:jarasa
ID: 10757654
Yes What?
You can't include an ASP to a JSP.
Javier
0
 

Author Comment

by:ericworldz
ID: 10757965
okay here's what i did to resolve the problem:
window.location = 'Annual_Report_c_r.pdf';
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 10758005
but this will not open up a new window...., it will open the PDF in the same window.....
0
 
LVL 6

Expert Comment

by:jarasa
ID: 10758023
Well I guess is been a missundertood, becose it wasn't opening 2 windows but keeping the opener one opened so this could worked to:

<%@include file="/site/includes/secure.jsp"%>
<!--%@include file="/site/includes/checklogin.jsp"%-->
<Script>
<!--
window.open('Annual_Report_c_r.pdf','','width=800,height=600,toolbar=1,location=0,directories=0,status=1,menubar=1,scrollbars=1,resizable=1');
window.close();
//-->
</Script>

Javier
0
 
LVL 2

Accepted Solution

by:
Lunchy earned 0 total points
ID: 10798160
Closed, 50 points refunded.
Lunchy
Friendly Neighbourhood Community Support Moderator
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
If something goes wrong with Exchange, your IT resources are in trouble.All Exchange server migration processes are not designed to be identical and though migrating email from on-premises Exchange mailbox to Cloud’s Office 365 is relatively simple…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

610 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