|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Canīt close my current window
Have a problem. the line:
Response.write "<td class=""form""><a href=""java script: document.close();"">option2</a></td>" & vbcrlf doesn't close my current window
__________________
atferraz |
|
#2
|
||||
|
||||
|
Since you aren't using ASP in the line, you can do it outside of ASP and at least eliminate one possible variable from the equation.
In any case, one problem might be that java and script are separated by a space, while I have always used them as one word. I don't know if it might help to add return; after document.close or use the javascript:window.close() method instead, which usually works for me. Since JavaScript depends on the browser, make sure your test browser (or whoever is reporting the bug) doesn't have JavaScript partially disabled or configure so that JavaScript doesn't have permissions to manipulate windows' opening and closing (one of the Mozilla features). |
|
#3
|
|||
|
|||
|
For some reason, and I don't know why, when I posted an answer to atferraz the order day, the word "javascript" was well written but when I submitted the reply, it created "java script" notice the "space" between "java" and "script"
So I then decided to edit my post, but when in edit mode it was written correctly so I saved the changes and the "space" was still there... anyway...the original poster, I hope, knows that its "javascript" and not "java script" Vlince |
|
#4
|
|||
|
|||
|
ok Vlince, I note it, but still have the problem. just can't close it. I put the code in a new thread but here it is again:
<% '.................... FORM SUB calls TabUserBDinsert() Sub TabUserBDinsert() If TabUserServerValidar("insert") = 1 then 'Before send the data it checks server side fields Opens_BD() SQLstm="Insert into TABLE(.....................)" rs.Open SQLstm,Lig,1,2 Close_BD() TabUserRedirect() ' If no errors go to new page end if End sub Function TabUserServerValidar(testeLg) Response.Write "<HTML><head><Link rel='stylesheet' type='text/css' href='../Fsource/Base_CSS_Geral.css'>" Response.Write "</head>" Response.Write "<body Class='Geral'>" Response.Write "<CENTER><BIG><b><font color='white'>ERRORS</font></b></BIG></CENTER><BR>" TESTE=1 Response.Write "<CENTER>" Response.Write "<FORM id=formUserServerError name=formUserServerError>" Response.Write "<TABLE Class=form>" Response.Write "<TR><TD>" mail=Request.Form ("mail") if len(mail)> 0 then if len(mail)> 70 then Response.Write "O mail não pode exceder os 70 carateres e colocou <B>" & len(mail) TESTE=0 end if end if Response.Write "</TD></TR>" Response.Write "</TABLE></CENTER>" Response.Write "<CENTER>" Response.Write "<TABLE border =0>" Response.Write "<TR><TD align='center' ><input type=button value=Back onClick='javascript:history.back(-1)' id=button1 name=button1></TD></TR>" Response.Write "</TABLE>" Response.Write "</FORM>" TabUserServerValidar=teste 'return teste value to TabUserBDinsert Response.Write "</body></html>" End Function Sub TabUserRedirect() ' this is a page option for user to decide directions Response.Write "<HTML><head><Link rel='stylesheet' type='text/css' href='../Fsource/Base_CSS_Geral.css'>" Response.Write "</head>" Response.Write "<body Class='Geral'>" Response.Write "<CENTER><BIG><b><font color='white'>DATA OK</font></b></BIG></CENTER><BR>" Response.write"<center>" Response.write"<table class='dadosOk'>" Response.write"<tr>" Response.write"<td Class='dadosOk'><a href='#' onClick='javascript:document.self.close();'>OUT 2 teste</td>" Response.write"</tr>" Response.write"</table>" Response.write"</center>" Response.Write "</body></html>" End Sub %> The problem is, if no errors the empty table from TabUserServerValidar() shows before this one (TabUserRedirect), and get two pages and two tables in the same window. I already tried to close that first page and this new one, as you can see, but doesn't work. Last edited by atferraz : September 5th, 2003 at 07:55 AM. |
|
#5
|
|||
|
|||
|
I don't fully understand what exactly is your question...
you say this doesn't work: ---BEGIN QUOTE--- Have a problem. the line: Response.write "<td class=""form""><a href=""java script: document.close();"">option2</a></td>" & vbcrlf doesn't close my current window ---END QUOTE--- Now that's because you need to use: window.close(); and *NOT* document.close(); But then you paste this entire mombo jumbo code and *I* still don't understand what is it your trying to do ![]() Anyway, I hope this fixes your problem ![]() Sincerely Vlince |
|
#6
|
|||
|
|||
|
already tried. window.close(), window.self.close(), document.close() and document.self.close(). Thatīs why I put the mombo jumbo.
That's how it works: 1) A form in a first sub send its fields to TabUserBDinsert() in order to get it into a DB. 2) TabUserBDinsert() check all that fields in the TabUserServerValidar() function before return the result to TabUserBDinsert(). In that process a table is created to show the errors. 3) if no DB errors found, TabUserRedirect() is call to give user some options. Now, my problem is that I get two pages in user final direction option window: the empty server side table verification of the TabUserServerValidar(), on top of direction table from TabUserRedirect(). Note that TabUserServerValidar() creates a table even if there is no errors found, a empty one. And it shows in the end of the process. How can I make that table disappears? thanks for your time Last edited by atferraz : September 5th, 2003 at 08:44 AM. |
|
#7
|
|||
|
|||
|
Why are you doing all that ???
Why do you complicate your life/code??? Why not: 1) Build a simple .asp page with a <form>...</form> 2) make that <form>'s action attribute equal to: page1.asp for example. So you'll end up having something like: <form name="frmMain" action="page1.asp" method="post"> . . . </form> 3) create the page1.asp page that retrieves the values entered in the <form>...</form> into variables 4) Make a validation on these variables, if they are not correct, simply redirect the user 5) Once everything is ok, create your INSERT query 6) Create your connection object 7) Execute using the connection object your INSERT query Keep it simple my friend otherwise you'll search forever until you find errors in that mombo jumbo code ![]() Vlince |
|
#8
|
||||
|
||||
|
suggested troubleshooting procedure
In order to trouble shoot it, I would solve one problem at a time:
JavaScript first, and then ASP conditionals second (or vice versa if you prefer...) To test the JavaScript, try using a static page which corresponds to what you expect the ASP output to send to the Browser on the Client, and get that working so that you know your goal (what the ASP should produce in terms of HTML+JavaScript for the browser to use). As I and others posted earlier, javascript:window.close(); should do the trick. If it doesn't, try to check the browser settings, or try it on a different browser. Once you know what you are trying to produce as final output, use the different ASP conditionals to preduce that code, checking the HTML Source on the browser to help you verify that you progressively near the goal. The important thing is to be methodical to obsession for this phase, as it will usually allow you to see some glaringly simple error, particularly if you debug with many variable prints using Response.Write |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > Canīt close my current window |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|