www.webdeveloper.com
Results 1 to 7 of 7

Thread: How to retrieve the current URL value

  1. #1
    Join Date
    Nov 2006
    Posts
    20

    How to retrieve the current URL value

    Hey friends, I would like to be intrsucted on how to retrieve the url value of the current page. I operate a page with an iframe inside it, and the iframe url is the url value I will need to retrieve. I am trying to create a "Full Screen" button which retrieves the value of of the iframe url and opens it up in a new window. I have been struggling with many different options but have had no luck so far. Any assistance would be greatly appreciated. Thanks

    -Steve

  2. #2
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,213
    myiframe is the iframe "id" tag property in the iframe, eg,
    HTML Code:
    <iframe id="myiframe" name="myiframe" src="mypage.html" frameborder="0" height="300" width="350" title="iframe" scrolling="no"></iframe>
    Then javascript gets the iframeurl with
    Code:
    iframeurl = document.getElementById("myiframe").src;
    That should be all thats needed to get the current URL of that iframe.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

  3. #3
    Join Date
    Nov 2006
    Posts
    20
    I greatly appreciate your help. In fact the code you provided was perfect... except for one small issue. The code only allows me to open the original value of the iframe url, and not the url of the framed page as it changes, say from google.com to yahoo.com. I've been testing this out in a 'test page' so I'll include the head to body code here, as well as the the test page (in txt format as htm isn't allowed) so you can better understand my problem.

    PHP Code:
    <head>

    <
    SCRIPT LANGUAGE="JavaScript">

    function 
    getURL() 
    {
        
    iframeurl document.getElementById("myiframe").src;
    }

    function 
    Start(page
    {
        
    OpenWin this.open(page"CtrlWindow""toolbar=yes,menubar=yes,location=yes,scrollbars=yes,resizable=yes");
    }

    </SCRIPT>

    </head>

    <body>

    <center>

    <div width="350">


        <a href="http://www.google.ca" target="myiframe">google</a> 
        <a href="http://www.yahoo.ca" target="myiframe">yahoo</a> 
        <a href="http://www.facebook.com" target="myiframe">facebook</a> 

        <P>

        <a href="#" onClick="history.go(-1)">back</a> 
        <a href="#" onmouseover="javascript:getURL()" onmousedown="javascript:Start(iframeurl)">FULL SCREEN</a> 
        <a href="#" onClick="history.go(+1)">forward</a> 

    </div>

    <p>

    <iframe id="myiframe" name="myiframe" src="" frameborder="0" height="300" width="350" title="iframe" scrolling="no"></iframe>

    </center>

    </body> 
    I believe there may be an error in the way I implemented the getElement parametre, but you guys are the experts so I'll leave the expertise to you.
    Thanks again,

    - Steve
    Attached Files Attached Files

  4. #4
    Join Date
    Nov 2006
    Posts
    20

    Exclamation Test Page Attachment Correction

    Sorry I posted the wrong attachement. Here is the proper one below in zip format. Thanks again.

    - Steve
    Attached Files Attached Files

  5. #5
    Join Date
    May 2007
    Location
    Cyberspace
    Posts
    23
    I think that iframe and browser security are your issue.

  6. #6
    Join Date
    Nov 2006
    Posts
    20
    Sorry, your reply wasn't very clear. Could you be more specific please? Or maybe provide an alternate suggestion? Thanks.

    - Steve

  7. #7
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,213
    What he said was the issue is the iframe and your browser security, I think, dont quote me but its built in security feature of the browser not to allow access beyond what you already have access to.

    I could be totally wrong but I think its that reason too.
    Yes, I know I'm about as subtle as being hit by a bus..(\\.\ Aug08)
    Yep... I say it like I see it, even if it is like a baseball bat in the nutz... (\\.\ Aug08)
    I want to leave this world the same way I came into it, Screaming, Incontinent & No memory!
    I laughed that hard I burst my colostomy bag... (\\.\ May03)
    Life for some is like a car accident... Mine is like a motorway pile up...

    Problems with Vista? :: Getting Cryptic wid it. :: The 'C' word! :: Whois?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles