Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Mar 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to make this code work in all browsers - I need some assistance please

    A few years ago I create a piece of code which I now wish to use again. The problem is that whilst it works very well in Internet Explorer it doesn't work the same in Chrome. I would appreciate any assistance this forum could offer me.

    Code:
    <HTML>
    <HEAD>
    <script type="text/javascript">
    
    
    function display(form) {
    	doc = open("","output");
    	doc.document.write(form.bg.value);
    	doc.document.close();
    	}
    
    
    </SCRIPT>
    </HEAD>
    <BODY>
    <CENTER>
    <form name="form1" target="" action="">
      <p>
    <iframe name="cwindow" style="border:10px double red" width=250 height=150 src="doc.htm"></iframe>
        <br><br><input type="button" value="Test" name="submit" OnClick="display(this.form)"> 
      </p>
      <p>
        <textarea style="width:100%" name="bg" wrap="logical" cols="42" rows="25">
    <HTML>
    <HEAD>
    </HEAD>
    <BODY>
    You can replace this text with whatever you wish.
    </BODY>
    </HTML>
    </textarea>
    </form>
    </center><p></p>
    </BODY>
    </HTML>

  • #2
    New to the CF scene
    Join Date
    Feb 2014
    Location
    Surat,Gujarat,India
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hey,

    send me full code so i can solve it....

    the code you have posted is not enough something missing...


    thanks

  • #3
    New to the CF scene
    Join Date
    Mar 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for the reply. This is the full code. What is missing is not part of the code but of the system. It consists of a frameset in which resides two html files. One of them contains the above code and is names 'input' and the other is a blank page named 'output'. The code above writes the html inside the textarea to the 'output' html frame. It operates similar to W3 'Tryit' editor.

  • #4
    Senior Coder
    Join Date
    Jan 2011
    Location
    Missouri
    Posts
    4,105
    Thanks
    23
    Thanked 594 Times in 593 Posts
    I added a doctype to your code, removed a few <p> tags and it works fine in FF, Chrome, IE(new ver), Opera, and Safari.
    Doctypes are important!

    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    Evolution - The non-random survival of random variants.

    "If you leave hydrogen alone, for long enough, it begins to think about itself."

  • #5
    New to the CF scene
    Join Date
    Mar 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the assistance. Your solution does work, in part. Below is the code for all the individual elements. I have 4 HTML pages controlled by my main page 'example.html' which organises the frameset.

    Example.html

    Code:
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <HEAD>
    <TITLE>Example</TITLE>
    </HEAD>
    <FRAMESET COLS="50%,*"> 
      <FRAME SRC="pick1.html" name="input">
      <FRAME SRC="blank.html" NAME="output">
    </FRAMESET>
    <noframes>
    </noframes> 
    </HTML>
    Doc.html

    Code:
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <head>
    <title>Untitled Document</title>
    </head>
    <body bgcolor="#FF9966" text="#000000">
    <p>Make any changes below and then click on the Test button.</p>
    <p>This is your first basic HTML page. Please study the layout and structure of 
      these pages.</p>
    </body>
    </html>
    Pick1.html

    Code:
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <HEAD>
    <script type="text/javascript">
    
    
    function display(form) {
    	doc = open("","output");
    	doc.document.write(form.bg.value);
    	doc.document.close();
    	}
    
    
    </SCRIPT>
    </HEAD>
    <BODY>
    <CENTER>
    <form name="form1" target="" action="">
      <p>
    <iframe name="cwindow" style="border:10px double red" width=250 height=150 src="doc.htm"></iframe>
        <br><br><input type="button" value="Test" name="submit" OnClick="display(this.form)"> 
      </p>
      <textarea style="width:100%" name="bg" wrap="logical" cols="42" rows="25">
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <HEAD>
    </HEAD>
    <BODY>
    You can replace this text with whatever you wish.
    </BODY>
    </HTML>
    </textarea>
    </form>
    </center>
    </BODY>
    </HTML>
    Blank.html

    Code:
    <!DOCTYPE html>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <head>
    
    <BODY>
    
    </BODY>
    
    </html>
    The idea is that the doc.html file will store some instructions; the pick1.html is the working area and the blank.html is where the contents of pick1 will be written. It all works fine in IE but not any other browser. Thanks for the help so far. I would appreciate it if someone could help me make it work in all browsers as it does in IE.

    Thanking you all in anticipation.

  • #6
    New to the CF scene
    Join Date
    Mar 2014
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks to all those who contributed a reply. I have managed to solve this problem myself by re-writing the code.


  •  

    LinkBacks (?)

    1. 03-03-2014, 09:42 AM

    Posting Permissions

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