Passing Referrer id to Javascript pop up window

Last post 07-07-2004 12:16 PM by wombar. 8 replies.

Sort Posts:

  • Passing Referrer id to Javascript pop up window

    07-01-2004, 11:52 AM
    • Member
      80 point Member
    • wombar
    • Member since 06-21-2004, 3:40 AM
    • Posts 16
    Hi All,

    Well after some good advice in the just starting forum I've come to you guys to see if you can help. Basically I'm trying to pass a referrer id from one site to a 2nd to a 3rd site.

    I've got the referrer id stored in a string variable sitting on the 2nd site and I basically need to find a way to incorporate this into a URL on a javascript pop up.

    Here is the complete page that I have so far


    <%@ Page Language="VB" %>
    <script runat="server">
    Sub Page_Load()
    Dim refer as string
    refer = request.querystring("referrerid")
    tester.NavigateURL = "javascript:window.open('pop.htm?referrerid=','mywindoww1','status=1,width=800,height=600, scrollbars=0')" + refer
    End Sub
    </script>
    <html>
    <body>
    <p>
    <asp:HyperLink id="tester" runat="server">java test</asp:HyperLink>
    </p>
    </body>
    </html>


    So my question is how do I append the "refer" variable onto the URL ('pop.htm?referrerid="CONTENTS OF REFER GO HERE"). Without the javascript pop up I can just use "+refer" at the end of the navigateURL but it's really important that the address bar is removed.

    Another problem that I'm having is the page with the link on goes to a page saying "[object]" after the pop up has appeared. Whats that about?

    Anyway, if you could help me out on this I'd be incredibly gratfeul.
  • Re: Passing Referrer id to Javascript pop up window

    07-01-2004, 12:53 PM
    • All-Star
      18,561 point All-Star
    • SreedharK
    • Member since 07-10-2003, 2:58 AM
    • Virginia
    • Posts 3,119
    • TrustedFriends-MVPs
    I guess below statement would works for you!

    tester.NavigateURL = "javascript:window.open('pop.htm?referrerid=" & refer & "','mywindoww1','status=1,width=800,height=600, scrollbars=0')"
    Sreedhar
    http://www.w3coder.org
    weblog http://weblogs.asp.net/skoganti
  • Re: Passing Referrer id to Javascript pop up window

    07-02-2004, 3:12 AM
    • Member
      80 point Member
    • wombar
    • Member since 06-21-2004, 3:40 AM
    • Posts 16
    Thanks SreedharK, that was exactly what I was looking for. Trouble is I just don't know the syntax rules yet, nice one.

    The only problem is that the window with the link then goes to a page with [object] on it. Unfortunately I need to keep the current page as it is once the link have been clicked and the new window is open.

    Any help as always is greatly appreciated.
  • Re: Passing Referrer id to Javascript pop up window

    07-02-2004, 7:45 AM
    • All-Star
      18,561 point All-Star
    • SreedharK
    • Member since 07-10-2003, 2:58 AM
    • Virginia
    • Posts 3,119
    • TrustedFriends-MVPs
    Can you make it more clear, then may be I can throw some light on it!
    Sreedhar
    http://www.w3coder.org
    weblog http://weblogs.asp.net/skoganti
  • Re: Passing Referrer id to Javascript pop up window

    07-02-2004, 8:31 AM
    • Member
      80 point Member
    • wombar
    • Member since 06-21-2004, 3:40 AM
    • Posts 16
    Thanks for the reply, I'll try to explain a bit more about what I'm trying to do, hopefully that will clear up any confusion.

    The steps I have to go through:

    1. A link is clicked (http://widget.aspx?referrerid=ADTR)
    2. widget.aspx is opened and I capture the referrerid in a string variable (refer = ADTR)
    3. A new link is clicked on widget.aspx and a Javascript popup is activated. (window.open('pop.htm?referrerid='#REFERRER VARIABLE#,'mywindoww1'))

    My problem is that I don't know how to get the referrerid into the popup window URL and preserve widget.aspx as it is. widget.aspx needs to stay the same after the pop up activates, it can reload but can't change

    The code that SreedharK posted above works fine if you are storing the whole URL in a string but you cannot use this variable name in a javascript as far as I am aware.

    Basically I need to get


    "javascript:window.open('pop.htm?referrerid=" #VARIABLE NAME GOES HERE#"','mywindoww1','status=1,width=800,height=600, scrollbars=0')"


    into this asp label in the OnClick event.


    <asp:HyperLink id="HyperLink1" onclick="#POP UP CODE GOES HERE#" runat="server" NavigateUrl="#">CLICK ME</asp:HyperLink>


    The navigate URL needs to stay as "#" because if you put the javascript code into the navigate URL the pop up works but widget.aspx goes to a page saying [object]

    I hope this is a little clearer.

  • Re: Passing Referrer id to Javascript pop up window

    07-02-2004, 12:41 PM
    • All-Star
      18,561 point All-Star
    • SreedharK
    • Member since 07-10-2003, 2:58 AM
    • Virginia
    • Posts 3,119
    • TrustedFriends-MVPs
    OK, I got it!

    Here is the simple example I made for your need, please use this as example and go further!


    Code for xyz.aspx

    <%@ Page Language="VB"%>

    <script runat="Server">

    sub Page_Load(obj as object, e as eventargs)

    lblMessage.text = "Welcome to ASP.net!"

    Dim refer as string

    refer = request.querystring("referrerid")

    tester.NavigateURL = "javascript:openwindow('test.aspx?referrerid=" & refer & "')"

    end sub

    </script>

    <html>

    <body>

    <asp:label id="lblMessage" runat="server"/>

    <asp:HyperLink id="tester" runat="server">java test</asp:HyperLink>

    </body>

    </html>
    <script language="javascript">
    function openwindow (url)
    {
    var hwd;
    hwd = window.open(url,'mywindoww1','status=1,width=800,height=600, scrollbars=0')
    }
    </script>




    Hope now it helps!
    Sreedhar
    http://www.w3coder.org
    weblog http://weblogs.asp.net/skoganti
  • Re: Passing Referrer id to Javascript pop up window

    07-02-2004, 5:16 PM
    • Member
      80 point Member
    • wombar
    • Member since 06-21-2004, 3:40 AM
    • Posts 16
    I truly bow down to your magnificence:) That's exactly what i was looking for, thanks very much.

    Is there any chance you could give me a quick run through of what that does. I understand what each line does but I don't quite understand how or why it works.

    Once again thanks a lot:D
  • Re: Passing Referrer id to Javascript pop up window

    07-05-2004, 8:52 AM
    • All-Star
      18,561 point All-Star
    • SreedharK
    • Member since 07-10-2003, 2:58 AM
    • Virginia
    • Posts 3,119
    • TrustedFriends-MVPs
    Well, that's simple, as it's expecting object when you pass value, I have created a seperate function and I assigned it to an object! The reason it is looking would be, as it needs a new handler!
    Sreedhar
    http://www.w3coder.org
    weblog http://weblogs.asp.net/skoganti
  • Re: Passing Referrer id to Javascript pop up window

    07-07-2004, 11:54 AM
    • Member
      80 point Member
    • wombar
    • Member since 06-21-2004, 3:40 AM
    • Posts 16
    Thanks Sreedhark, I really appreciate your help.
Page 1 of 1 (9 items)