/    Sign up×
Community /Pin to ProfileBookmark

Bring Popup to front

I use this code

[COLOR=DarkRed]p.RegisterClientScriptBlock(“OpenReport”, “<script language=’javascript’>window.open(‘http://xxx/xxx/reports/” + pFilePath + “.pdf’); window.top;</script>”);[/COLOR]

to open a new window with a PDF report.

It works good on most pages, but on a few of the pages the opener page always jumps to the front. Is there a way to send the new window forward, or the opener back?
Thanks

Ray

to post a comment
JavaScript

10 Comments(s)

Copy linkTweet thisAlerts:
@gil_davisSep 29.2006 — If you are using a hyperlink onclick to open the new page, make sure you use "return false" at the end of the onclick string. Otherwise, the opener will execute the standard href action and bring the opener into focus.
Copy linkTweet thisAlerts:
@raynkelauthorSep 29.2006 — I am calling the function right after exporting the PDF

I tried changing to this:

[COLOR=DarkRed]p.RegisterClientScriptBlock("OpenReport", "<script language='javascript'>window.open('http://xxx/xxx/reports/" + pFilePath + ".pdf'); [B]false;</[/B]script>");[/COLOR]

with no difference.
Copy linkTweet thisAlerts:
@Mr_JSep 29.2006 — See if this works

p.RegisterClientScriptBlock("OpenReport", "<script language='javascript'>newWin=window.open('http://xxx/xxx/reports/" + pFilePath + ".pdf'); newWin.focus();</script>");
Copy linkTweet thisAlerts:
@gil_davisSep 29.2006 — I am calling the function right after exporting the PDF

I tried changing to this:

[COLOR=DarkRed]p.RegisterClientScriptBlock("OpenReport", "<script language='javascript'>window.open('http://xxx/xxx/reports/" + pFilePath + ".pdf'); [B]false;</[/B]script>");[/COLOR]

with no difference.[/QUOTE]

That was not my suggestion. How are you calling the function?
Copy linkTweet thisAlerts:
@raynkelauthorSep 29.2006 — See if this works

p.RegisterClientScriptBlock("OpenReport", "<script language='javascript'>newWin=window.open('http://xxx/xxx/reports/" + pFilePath + ".pdf'); newWin.focus();</script>");[/QUOTE]


Sorry that didn't work,

Thanks
Copy linkTweet thisAlerts:
@raynkelauthorSep 29.2006 — That was not my suggestion. How are you calling the function?[/QUOTE]


In the C# code I use:

[COLOR=Navy]oDoc.ExportOptions.DestinationOptions = oDiskOption;

oDoc.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;

oDoc.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;

oDoc.ExportOptions.FormatOptions = new PdfRtfWordFormatOptions

oDoc.Export();

[/COLOR]


That creates a PDF with the sessionID as its name

[COLOR=Navy]

Global.ShowRaysReport(Session.SessionID, this, "pdf");

[/COLOR]


The call to [COLOR=Navy]Global.ShowRaysReport [/COLOR] is a public static void in my Global.asax.cs file.

Thanks for the help
Copy linkTweet thisAlerts:
@gil_davisSep 29.2006 — I wanted to know how the browser calls the function. What does the user have to do to get the report?
Copy linkTweet thisAlerts:
@raynkelauthorOct 02.2006 — They click a button that does a postback that generates the pdf and then runs the function that writes the script that opens the new window.
Copy linkTweet thisAlerts:
@gil_davisOct 02.2006 — They click a button that does a postback that generates the pdf and then runs the function that writes the script that opens the new window.[/QUOTE]This is important. When you say "postback" do you mean that the ACTION of the FORM is the same web page? If so, then there is a timing issue between the button click, the "postback", the creation of the new window and the load of the pdf file in the new window. Since "newWin.focus()" did not help, perhaps the newWin had not finished loading. If that is the case, perhaps you can include an onload handler for newWin:newWin.onload = function () {window.focus();}
Copy linkTweet thisAlerts:
@raynkelauthorOct 02.2006 — This is an ASP.Net application.

That didn't work.

Thanks, gonna just leave it as is. just a small thing.
×

Success!

Help @raynkel spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.17,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...