Click to See Complete Forum and Search --> : Close parent window


lmf232s
08-17-2004, 10:10 AM
Is there any way to close a parent window.

I send out an email, and the email contains a link to a file on our web server(This is on the intranet).
The user clicks on the link and it opens a web page
And then through code i open the file.
The file opens but i have it so that it opens in its own
program(say like word)

Currelty the parent window stays open until you click on the X to close it, I had javascript up to close the window, but users were anoyed with this message " this window is trying to close. would you like to close it" So i took out the javascript>

Does anytone know of a way to close this window with code.

Tahnks.

slyfox
08-17-2004, 05:26 PM
You cannot close the parent window without getting "the warning message"...

Alternative: (haven't doen it before, but it might work)
That link you email to the user to click on, make that file a pure asp file that redirects (instead of opening new window) to your desired file (eg. msword).

eg. Response.Redirect = "somefile.doc"

Hope it works!

lmf232s
08-17-2004, 05:39 PM
ya i was doing that but their in lies another problem.

The type of file that we are emailing are drawing files either an autocad file or a solidworks file.

The problem with this is that the viewer that people use to view these files is able to run with in Internet explore.

SO when you do that, instead of it opening the viewer it opens the file in Internet explorer.

I was having users complain that it was opening in IE instead of their viewer. boooohoooo, live with it.

So thats the problem i run into with that way.

slyfox
08-17-2004, 06:00 PM
Ok, you say it works the other way except you cannot get the parent window closed right?

If so, here is something else you can try..

If you close a newly opened (popup) window with javascript, it won't give you the error message, instead it will close your window with no questions asked.

So what I'm saying is open the file in a new window(popup) directly from the email and then you have no problem in closing it after the cad file is opened... because it's no longer a parent window...

Hope it helps this time round... else teach the users how to right-click and save the file... hehe! Just a thought =)

buntine
08-17-2004, 08:54 PM
Just a note, there is no way to close the parent window from the server. ASP cannot interact with the users software, but can only generate HTML and other client-based code.

You must use a client-side language to dynamically close a window.

Regards.

lmf232s
08-18-2004, 10:31 AM
slyfox you are on to something.
Yes I like the idea of opening a new window when they click on the link but i am having problems with the syntax.

When i create the email. Everything is created using serverside code(the body and all the links).

So what I was gonig to do was take the
<a href="Somepage.asp">Click Me</a>

And make it so it opens a new window to the page that is needed.

In my test runs using client side code(html with javascript embeded)

<a Href="#" onclick="window.open('http://idiapp/ImageViewer/ImageViewer.asp?&Ext=dwg&File=<%=TextMe%>');">clickme</a>

This works correctly. Opens a new window, fires the code to open the program at the cmd line and then closes out the window.
Works like a charm.

The problem I now have is that i can not get this code to work Server side. this example.

Response.Write "<a href=""#"" onlcick=""window.open('http://idiapp/ImageViewer/ImageViewer.asp?&Ext=dwg&File=" & TextMe & "', 'Plunger');"">clickme</a>"

But the thing is when you run the code with both of these lines, and then view the source. They are identical, only thing is that the one done with html works and the server side does not work.

Any ideas.

Paste both of these lines and run it. Then view the source. Maybe i have something incorrect causing this not to fire.



<%Dim TextMe
TextMe = "44344"
Response.Write "<a href=""#"" onlcick=""window.open('http://idiapp/ImageViewer/ImageViewer.asp?&Ext=dwg&File=" & TextMe & ");"">clickme</a>"
%>
<a Href="#" onclick="window.open('http://idiapp/ImageViewer/ImageViewer.asp?&Ext=dwg&File=<%=TextMe%>');">clickme</a>

slyfox
08-18-2004, 04:56 PM
You missed out on a single quote '

Try this:

<%Dim TextMe
TextMe = "44344"
Response.Write "<a href=""#"" onlcick=""window.open('http://idiapp/ImageViewer/ImageViewer.asp?&Ext=dwg&File=" & TextMe & "');"">clickme</a>"
%>


hehe... it's sometimes the simplest of things that gets us under =)

lmf232s
08-18-2004, 05:02 PM
Ya, I eventually got it to work(out side of an email) earilier.

But for what ever reason, It just does not want to fire out of an outlook email.

I even tried putting the onclick statement inside the href=" "
with out the onclick= of course.
This is actually the only one that came close.

when you clicked on a link, it would open a page and then open the page it needed to, close that one out and run the program. BUt it left the first initail window open. In the address bar it showed up something like this
javascript:window.open................
So I finally said screw it.

This would not be a problem if the files were uploaded and sent as attachments, but we feel its a better idea to give them links to the file.

All the files already exist out on the file server, the email just gives them a link to the drawing without exploring out to the server and finding it.

Oh well. Back at square one.

Unless you have another idea on how this would work.

It works correctly if you are just running an asp page but it does not want to work out of outlook.

Thanks.