locked
Can't call javascript with vb RRS feed

  • Question

  • User565442435 posted

    I have a javascript function that should open a pop up window like so

     

            function callBackWindow(url) {
    
                 window.open(url, 'OpenWindow', 'width=1000,height1000,left=-10,top=-10,scrollbars=no');
                 return false;
    
             } //callBack

    However, when I call it with vb nothing happens any ideas why?

    Page.ClientScript.RegisterStartupScript(Me.GetType, "callBackNow", "<script type='text/javascript'>callBackWindow(""callBack.aspx"");</script>")

     

     

    Monday, April 25, 2011 4:23 PM

Answers

  • User565442435 posted

    I thought that, so I hard coded the link i.e. http://domain.com/callback.aspx. I ended up figuring out it was chrome. The pop up was working in IE and FF.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 27, 2011 9:15 AM

All replies

  • User198012145 posted

    you code is fine with one quote issue

     

    Page.ClientScript.RegisterStartupScript(Me.GetType, "callBackNow", "callBackWindow('"callBack.aspx"');", true)

     

    in the above code I have only replaced double quote with singe one in callBack.aspx

    and rest is fine.

    Tuesday, April 26, 2011 3:00 AM
  • User565442435 posted

    This ' " does not work because it closes the string. In VB two " together makes it write 1 " (it's like \" in php or JS). My JS that get's generated is complete valid

    <script type='text/javascript'>callBackWindow("callBack.aspx");</script>

    I think it's something with the JS, I just don't know what.

    Tuesday, April 26, 2011 9:06 AM
  • User-1423995609 posted

    is your callBack.aspx page within root folder in your solution? I think problem is you passing page's path wrong, if it's within root folder you should use 

    <script type='text/javascript'>callBackWindow("~/callBack.aspx");</script>

    or

    <script type='text/javascript'>callBackWindow("../callBack.aspx");</script>

     

    Tuesday, April 26, 2011 9:10 AM
  • User565442435 posted

    I thought that, so I hard coded the link i.e. http://domain.com/callback.aspx. I ended up figuring out it was chrome. The pop up was working in IE and FF.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, April 27, 2011 9:15 AM
  • User-29804325 posted

    Hi,

    You can also try single quote

     Page.ClientScript.RegisterStartupScript(Me.GetType, "callBackNow", "<script type='text/javascript'>callBackWindow('callBack.aspx');</script>")

    Instead of

    Page.ClientScript.RegisterStartupScript(Me.GetType, "callBackNow", "<script type='text/javascript'>callBackWindow(""callBack.aspx"");</script>")

    to see if it make sense.

    Hope this can help you.

    Thursday, April 28, 2011 2:56 AM