Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: I need help with SCR

  1. #1
    Join Date
    Jan 2008
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default I need help with SCR

    Hi
    I am trying to run an external javascript that is on one of my other systems

    When i view the source of the page the code i see is
    Code:
    <SCRIPT language="JavaScript"> 
    document.write('<iframe width="400" height="200" allowtransparency="true" scrolling="no" frameborder="0" hspace="0" vspace="0" src="/websnips copy/index.php/widget/show/aHR0cDovL3d3dy5iYmMuY28udWsvbG9uZG9uL25ld3Mv/156"></iframe>');
    </SCRIPT>

    I am trying to create a document like this
    Code:
    <script type="text/javascript" src="http://localhost:8888/websnips%20copy/index.php/widget/widget/aHR0cDovL3d3dy5iYmMuY28udWsvbG9uZG9uL25ld3Mv/156"></script>
    Which should embed the script above it, but it doesn't. Can anyone help me fix this problem?

    Thanks

  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

    Is this all local (LAN)? I ask because that looks like a local path. Anyways, I'm having trouble following you. But there are two things we should get straight:

    • Why an iframe?
    • Are you trying to import a page or a script?


    Oh, and just as a side note, don't use the deprecated language attribute in a script tag, and do use the required type attribute.

    Now, if what you want to create with javascript is:

    Code:
    <script type="text/javascript" src="http://localhost:8888/websnips%20copy/index.php/widget/widget/aHR0cDovL3d3dy5iYmMuY28udWsvbG9uZG9uL25ld3Mv/156"></script>
    do:

    Code:
    <script type="text/javascript">
    document.write('<script type="text/javascript" src="http://localhost:8888/websnips%20copy/index.php/widget/widget/aHR0cDovL3d3dy5iYmMuY28udWsvbG9uZG9uL25ld3Mv/156"><\/script>');
    </script>
    - John
    ________________________

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

  3. #3
    Join Date
    Jan 2008
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Thanks for your help. I am testing it on a local server yes, however it is for my website. Basically what i want is for my users to be able to embed this widget using an src however i was under the impression that i wouldn't be able to just src the file i want them to embed because it is html not js. Hence i used the iframe to make it javascript, and enable them to SRC it.

    do you understand now?

    Any advice?

    Thanks

  4. #4
    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

    I get it a little better. If you want folks to embed something on their site, if it is a page, you can just tell them to put the iframe containing it directly into their code or you could have a script that writes out the tag for them.
    - John
    ________________________

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

  5. #5
    Join Date
    Jan 2008
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Is my way not possible? the problem is many people do not like iframes and also i find them quite buggy to work with. I have seen other sites that seem to be using the method i described.

    Thanks

  6. #6
    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

    The trouble is I really don't understand what you are describing. Can you give me a link to a page that uses the method you want? And, could you try describing it better?
    - John
    ________________________

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

  7. #7
    Join Date
    Jan 2008
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Yeh sure one example is http://widgeteasy.com which lets the user generate a widget out of a feed.

    1) The widget is constructed out of html,
    See http://www.widgeteasy.com/rsswid.php?fid=201 (view source)


    2) this page is then ifamed in javascript
    http://www.widgeteasy.com/rss.v1.js
    Code:
    document.write('<iframe width="100%" height="312" allowtransparency="true" scrolling="no" frameborder="0" hspace="0" vspace="0" src="http://www.widgeteasy.com/rsswid.php?fid='+bunnywid.fid+'"></iframe>');
    3) this js is then embedded into the site and given as an embed code using SCR
    http://www.widgeteasy.com/widget.php?fid=201
    Code:
    <script type="text/javascript">bunnywid = { fid: 1108 };</script><script type="text/javascript" src="http://www.widgeteasy.com/rss.v1.js"></script>

    Thanks for all your help.
    Last edited by ojsimon; 11-16-2008 at 02:48 PM. Reason: Adding more info

  8. #8
    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

    Well this is all that is in that (http://www.widgeteasy.com/rss.v1.js) script:

    Code:
    document.write('<iframe width="100%" height="312" allowtransparency="true" scrolling="no" frameborder="0" hspace="0" vspace="0" src="http://www.widgeteasy.com/rsswid.php?fid='+bunnywid.fid+'"></iframe>');
    So, you can do that sort of thing too. It requires that you have a page to serve, as the widget site does:

    http://www.widgeteasy.com/rsswid.php

    The customizing fid used by their server's PHP interpreter is passed via:

    Code:
    <script type="text/javascript">bunnywid = { fid: 201 };</script>
    in that part of the code that is put on the user's page and picked up in their script with:

    Code:
     . . . teasy.com/rsswid.php?fid='+bunnywid.fid+'"></ifram . . .
    - John
    ________________________

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

  9. #9
    Join Date
    Jan 2008
    Posts
    46
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default

    Hi
    sorry i don't quite understand what you suggest i do?

    Thanks

  10. #10
    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

    Do you have a page to serve? If so, use that here with its full path to its location on your server:

    Code:
    document.write('<iframe width="100%" height="312" allowtransparency="true" ' +
    'scrolling="no" frameborder="0" hspace="0" vspace="0" ' +
    'src="your page goes here"></iframe>');
    Save that file as whatever.js and give your users the address to it to put on their page, ex:

    Code:
    <script src="http://full_path_on_your_server_to/whatever.js" type="text/javascript"></script>
    Now, if your page (your page goes here) is a PHP page and you want your users to pass a code to it, you can have them use two scripts (like what the widget site does):

    Code:
    <script type="text/javascript">var myObject = { fid: 201 };</script>
    <script src="http://full_path_on_your_server_to/whatever.js" type="text/javascript"></script>
    Then in your whatever.js (add red):

    Code:
    document.write('<iframe width="100%" height="312" allowtransparency="true" ' +
    'scrolling="no" frameborder="0" hspace="0" vspace="0" ' +
    'src="your page goes here?fid=' + myObject.fid + '"></iframe>');
    - 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
  •