Results 1 to 2 of 2

Thread: Need to change the SRC atribute of an Iframe on button click

  1. #1
    Join Date
    Jul 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need to change the SRC atribute of an Iframe on button click

    Hi ALL,

    I need to the SRC atribute of an Iframe on a button click.

    I have displayed a pdf file in an Iframe.

    <IFRAME SRC= "E:\Documents\general docs\SDKJSSnippet1.pdf" ID="testiframe"
    NAME="testiframe" SCROLLING=yes WIDTH=500 HEIGHT=400 ALIGN=MIDDLE></IFRAME>

    Next, I have a textbox with some text (say 'pdf') in it. Now when I click a button, the SRC attribute in the Iframe should change to "E:\Documents\general docs\SDKJSSnippet1.pdf#search='pdf'" . ie, #search='pdf' should be concatenated with the SRC attribute in the end.

    Please give me the code to do this ASAP.

    thanks & regards,
    Achyuta

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Code:
    <script type="text/javascript">
    function getTerm(){
    var srchStr=document.getElementById('searchBox').value
    return srchStr
    }
    </script>
    <input type="text" id="searchBox">
    <input type="button" value="Search" onmousedown="testiframe.location.replace('blank.htm');" onmouseup="testiframe.location.replace('E:\Documents\general docs\SDKJSSnippet1.pdf#search=#search=\''+getTerm()+'\'')">
    <iframe name="testiframe" src="E:\Documents\general docs\SDKJSSnippet1.pdf#search="></iframe>
    You may have to replace the space in the pathname with %20 to get this to work. Also, adjust the iframe's properties (size, scrolling, etc.) to suit. Requires 'blank.htm':
    Code:
    <html>
    <head>
    <title></title>
    </head>
    <body>
    
    </body>
    </html>
    This last bit might not be needed. I didn't want to test on an actual .pdf file. You could try it without this by removing the onmousedown event and see what happens. Is this for local or internet use?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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