How do I show source code in iframe

Discussion in 'PHP' started by HighRankingSEO, Dec 17, 2009.

  1. #1
    I am trying to make a little widget kind of...anyway, here is the actual widget so far:
    http://userbility.net/begin.php

    If you enter the detaisl it will grab the values and post them to the next page- end.php....oln end.php there is a button that says " click to get code" and I am trying to figure out how to make that iframe contain the source code for the user to copy/paste onto their site....

    If you run through the steps you will see what I am talking about...how do I do this?

    In the end, they will click the "click to get code" and then it will show something like this in the iframe:
    My name is Sean and I am an alcoholic with 
    <script>
    
    /*
    Count up from the date
    */
    
    var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
    
    function countup(yr,m,d){
    var today=new Date()
    var todayy=today.getYear()
    if (todayy < 1000)
    todayy+=1900
    var todaym=today.getMonth()
    var todayd=today.getDate()
    var todaystring=montharray[todaym]+" "+todayd+", "+todayy
    var paststring=montharray[m-1]+" "+d+", "+yr
    var difference=(Math.round((Date.parse(todaystring)-Date.parse(paststring))/(24*60*60*1000))*1)
    difference+=" days"
    document.write("<strong>"+difference+"</strong> sober!")
    }
    //enter the count up date using the format year/month/day
    countup(2009,12,15)  </script>   
    Code (markup):
    I tried to make that whole block of code a variable and echo it and tried to just straight echo it right from the get go
    but I really can't figure this out as a am VERY VERY new to PHP. I will shorten the JS once I figure out how to get this part done...so it just echos back something like:
    <SCRIPT LANGUAGE="JavaScript" SRC="http://userbility.net/js/therefile1998.js">

    ...but for now, I just have to figure this part out....lol
     
    HighRankingSEO, Dec 17, 2009 IP
  2. HighRankingSEO

    HighRankingSEO Well-Known Member

    Messages:
    423
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    125
    #2
    HighRankingSEO, Dec 17, 2009 IP
  3. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I don't really understand the question but you don't want the script executed but show the source code instead, right?

    I think you can just replace < with &lt; and > with &gt; and so on..
     
    Dondon2d, Dec 17, 2009 IP
  4. HighRankingSEO

    HighRankingSEO Well-Known Member

    Messages:
    423
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    125
    #4
    I want the code generated on end.php to show up as html/js in the frame
     
    HighRankingSEO, Dec 18, 2009 IP
  5. Dondon2d

    Dondon2d Peon

    Messages:
    3,193
    Likes Received:
    146
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yea I think you can do what I suggested above.
     
    Dondon2d, Dec 18, 2009 IP
  6. HighRankingSEO

    HighRankingSEO Well-Known Member

    Messages:
    423
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    125
    #6
    Thanks, worked. Just used ASCII....duno why I didnt think of that
     
    HighRankingSEO, Jan 25, 2010 IP