javascript open.window not quite right...
-
When you look at this I already know about string builder. I sometimes format my posts to make them smaller the + does that. tmpHtml += " <td class=\"tblrow\"><a href=JavaScript:window.open('" + thisReader["EVENT_PAGE_NAME"].ToString().Trim() + "', '', 'width=600,height=370,scrollbars=yes,screenX=400'" + ") class=\"tblrow\">" + thisReader["EVENT_CENTER"].ToString().Trim() + "</a></td>" + "\n"; tmpHtml gets passed to an asp:literal and written as HTML output. For some reason I cannot get this javascript to work. If the window does open correctly the window it launched from navigates to a blank page with the word [object] just like that. Can anyone see what I'm doing wrong?
-
When you look at this I already know about string builder. I sometimes format my posts to make them smaller the + does that. tmpHtml += " <td class=\"tblrow\"><a href=JavaScript:window.open('" + thisReader["EVENT_PAGE_NAME"].ToString().Trim() + "', '', 'width=600,height=370,scrollbars=yes,screenX=400'" + ") class=\"tblrow\">" + thisReader["EVENT_CENTER"].ToString().Trim() + "</a></td>" + "\n"; tmpHtml gets passed to an asp:literal and written as HTML output. For some reason I cannot get this javascript to work. If the window does open correctly the window it launched from navigates to a blank page with the word [object] just like that. Can anyone see what I'm doing wrong?
Hi, Try writing the code for opening window in a java script function on the same page and then call that function where you want actually the window should be opened. Embedding the window.open() function in our own function sorts this problem. I think window.open() returns some value and that is displayed in the source window. But when we write our own javascript function which does not return anything the returned value is not displayed in the window. This will definately solve your problem, because some days ago i also faced the same problem and following the above procedure it worked fine. Give it a shot. Anant Y. Kulkarni
-
When you look at this I already know about string builder. I sometimes format my posts to make them smaller the + does that. tmpHtml += " <td class=\"tblrow\"><a href=JavaScript:window.open('" + thisReader["EVENT_PAGE_NAME"].ToString().Trim() + "', '', 'width=600,height=370,scrollbars=yes,screenX=400'" + ") class=\"tblrow\">" + thisReader["EVENT_CENTER"].ToString().Trim() + "</a></td>" + "\n"; tmpHtml gets passed to an asp:literal and written as HTML output. For some reason I cannot get this javascript to work. If the window does open correctly the window it launched from navigates to a blank page with the word [object] just like that. Can anyone see what I'm doing wrong?
Hi, All you have to do is pass the returned value of the window.open method to a variable. the code below shows you how to do that: private void Page_Load(object sender, System.EventArgs e) { string tmpHtml = "event center"; Response.Write(tmpHtml); } As you can see, all I'm doing is setting the dummy obj variable with the returned value of the window.open method. By doing this it eliminates the [object] error. If you want to chat with me live, go to the Chat Room of the www.KYNOU.com website. sfdsfsdf
-
When you look at this I already know about string builder. I sometimes format my posts to make them smaller the + does that. tmpHtml += " <td class=\"tblrow\"><a href=JavaScript:window.open('" + thisReader["EVENT_PAGE_NAME"].ToString().Trim() + "', '', 'width=600,height=370,scrollbars=yes,screenX=400'" + ") class=\"tblrow\">" + thisReader["EVENT_CENTER"].ToString().Trim() + "</a></td>" + "\n"; tmpHtml gets passed to an asp:literal and written as HTML output. For some reason I cannot get this javascript to work. If the window does open correctly the window it launched from navigates to a blank page with the word [object] just like that. Can anyone see what I'm doing wrong?
Sorry!!! When I pasted my code it seems that CodeProject removed the actual code and shows a link. The missing part is showing you that all you have to change in your code is make sure the returned value from the window.open method is stored in a dummy variable. JavaScript:var obj = window.open( Again, if I didn't explain well in this little note, contact me at www.KYNOU.com