Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. javascript open.window not quite right...

javascript open.window not quite right...

Scheduled Pinned Locked Moved ASP.NET
javascripthtmlquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    code frog 0
    wrote on last edited by
    #1

    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?

    C O 3 Replies Last reply
    0
    • C code frog 0

      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?

      C Offline
      C Offline
      coolestCoder
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • C code frog 0

        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?

        O Offline
        O Offline
        OmegaCD
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • C code frog 0

          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?

          O Offline
          O Offline
          OmegaCD
          wrote on last edited by
          #4

          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

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups