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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 27
  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Location
    Port Huron, MI, U.S.A.
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question JS applet customizer

    I have desgined a JS that will allow you to type in parameters for an applet and display it in an iframe (with the help of some of you in my targeting an iframe string). Currently all you should change are the first 2 colors (ca,cb/coloraa/colorbby) when playing with it. The code goes as follows:

    ------------------------------------------------------------------------

    <script>
    <!--hide
    function dip() {
    var ca;
    var cb;
    var frames;
    var cs;
    var neg;
    var pos;
    var speed;
    var den;

    ca="document.thing.coloraa.value";

    ca="document.thing.colorbby.value";

    ca="document.thing.frames.value";

    ca="document.thing.cs.value";

    ca="document.thing.neg.value";

    ca="document.thing.pos.value";

    ca="document.thing.speed.value";

    ca="document.thing.den.value";

    var oIFrame = document.getElementById('i'),
    oFramedDoc = typeof oIFrame.contentDocument != 'undefined'?
    oIFrame.contentDocument: // W3C way
    typeof oIFrame.contentWindow != 'undefined'?
    oIFrame.contentWindow.document: // Microsoft way
    typeof oIFrame.document != 'undefined'?
    oIFrame.document: // Traditional way
    null; // And no way.
    if(oFramedDoc != null){
    oFramedDoc.open();
    oFramedDoc.write('<applet code="Wave" width="300" height="150" alt="Wave applet" align="center" vspace="5"><param name="color1" value="'+ca+'"><param name="color2" value="'+cb+'"> <param name="frames" value="'+frames+'"> <param name="colors" value="'+cs+'"> <param name="neg" value="'+neg+'"> <param name="pos" value="'+pos+'"> <param name="speed" value="'+speed+'"> <param name="density" value="'+den+'"></applet>') }
    }
    //--></script>
    </head><body bgcolor=royalblue>
    <iframe ID="i" width=307 height=157></iframe>
    <form name="thing" onSubmit="dip()">
    <input type=text size=22 name="coloraa" value="enter hex code here">
    <input type=text size=22 name="colorbby" value="enter hex code here">
    <input type=text size=22 name="frames" value="32">
    <input type=text size=22 name="cs" value="256">
    <input type=text size=22 name="neg" value="2">
    <input type=text size=22 name="pos" value="2">
    <input type=text size=22 name="speed" value="50">
    <input type=text size=22 name="den" value="100">
    <input type=submit value="Make Applet Happen" style="border-style:ridge" style="border color:blue" style="background-image:URL(g7.bmp)" style="color:aqua;font-weight:bold;font-style:italic">
    </form>

    -------------------------------------------------------------------------------
    I can't fiqure out why it won't work. Any ideas?

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    For one, you keep changing the value of ca:
    eg:
    Code:
    ca="document.thing.coloraa.value";
    
    ca="document.thing.colorbby.value";
    
    ca="document.thing.frames.value";
    
    ca="document.thing.cs.value";
    
    ca="document.thing.neg.value";
    
    ca="document.thing.pos.value";
    
    ca="document.thing.speed.value";
    
    ca="document.thing.den.value";
    And the values of neg, pos, speed and den are undefined.

    Code:
    <param name="neg" value="'+neg+'">
    <param name="pos" value="'+pos+'">
    <param name="speed" value="'+speed+'">
    <param name="density" value="'+den+'">
    Try something like this:
    neg="document.thing.neg.value";

    .....Willy

  • #3
    Regular Coder
    Join Date
    Jan 2004
    Location
    Port Huron, MI, U.S.A.
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Yeah, I figured out the "ca" thing about an hour after I posted. Now it looks like this:


    <script type="text/javascript" language="Javascript">
    <!--hide
    function dip() {
    var ca="document.thing.coloraa.value";

    var cb="document.thing.colorbby.value";

    var frames="document.thing.frames.value";

    var cs="document.thing.cs.value";

    var neg="document.thing.neg.value";

    var pos="document.thing.pos.value";

    var speed="document.thing.speed.value";

    var den="document.thing.den.value";

    var oIFrame = document.getElementById('i'),
    oFramedDoc = typeof oIFrame.contentDocument != 'undefined'?
    oIFrame.contentDocument: // W3C way
    typeof oIFrame.contentWindow != 'undefined'?
    oIFrame.contentWindow.document: // Microsoft way
    typeof oIFrame.document != 'undefined'?
    oIFrame.document: // Traditional way
    null; // And no way.
    if(oFramedDoc != null){
    oFramedDoc.open();
    oFramedDoc.write('<applet code="Wave" width="300" height="150" alt="Wave applet" align="center" vspace="5"><param name="color1" value="'+ca+'"><param name="color2" value="'+cb+'"> <param name="frames" value="'+frames+'"> <param name="colors" value="'+cs+'"> <param name="neg" value="'+neg+'"> <param name="pos" value="'+pos+'"> <param name="speed" value="'+speed+'"> <param name="density" value="'+den+'"></applet>') }
    }
    //--></script>
    </head><body bgcolor=royalblue>
    <iframe ID="i" width=307 height=157></iframe>
    <form name="thing" onSubmit="dip()">
    <input type=text size=22 name="coloraa" value="hex code here, please">
    <input type=text size=22 name="colorbby" value="hex code here">
    <input type=text size=22 name="frames" value="32">
    <input type=text size=22 name="cs" value="256">
    <input type=text size=22 name="neg" value="2">
    <input type=text size=22 name="pos" value="2">
    <input type=text size=22 name="speed" value="50">
    <input type=text size=22 name="den" value="100">
    <input type=submit value="Make Applet Happen" style="border-style:ridge" style="border color:blue" style="background-image:URL(g7.bmp)" style="color:aqua;font-weight:bold;font-style:italic">
    </form>


    After changing it, there is still an error.

  • #4
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    Hello -

    Not sure if this will fix the problem but I see:

    Code:
    var oIFrame = document.getElementById('i'),
    There shouldn't be a comma at the end there should there?

    Bassscyst
    Helping to build a bigger box. - Adam Matthews

  • #5
    Regular Coder
    Join Date
    Jan 2004
    Location
    Port Huron, MI, U.S.A.
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Should it be a ;?

  • #6
    Smokes a Lot
    Join Date
    Jul 2003
    Location
    CA, USA
    Posts
    1,594
    Thanks
    5
    Thanked 20 Times in 20 Posts
    I believe so, yes.
    Helping to build a bigger box. - Adam Matthews

  • #7
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Basscyst: It should be a comma, not a semicolon. (I should know, I wrote it for him.)
    It is more clear with original formatting, however:
    Code:
    var
         oIFrame = document.getElementById('i'),
         oFramedDoc = typeof oIFrame.contentDocument != 'undefined'?
              oIFrame.contentDocument: // W3C way
              typeof oIFrame.contentWindow != 'undefined'?
                   oIFrame.contentWindow.document: // Microsoft way
                   typeof oIFrame.document != 'undefined'?
                        oIFrame.document: // Traditional way
                        null; // And no way.


    Bobo: Hmm, what is the error? Where in the code? May it have something to do with that you write only an applet element and not a whole document to the iframe?
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #8
    Regular Coder
    Join Date
    Jan 2004
    Location
    Port Huron, MI, U.S.A.
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts
    The error once said syntax, and I don't even get one anymore, so it probably is the lack of an entire document like stated. It should work as just the applet, though, because when you first helped me with that code I successfully used it to test HTML/Javascript without having to re-load. The problem is that I don't know where in the code the error is or even what it is anymore.

  • #9
    Master Coder
    Join Date
    Feb 2003
    Location
    UmeŚ, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Try this:
    Code:
    function dip(){
        var
            ca=document.thing.coloraa.value,
            cb=document.thing.colorbby.value,
            frames=document.thing.frames.value,
            cs=document.thing.cs.value,
            neg=document.thing.neg.value,
            pos=document.thing.pos.value,
            speed=document.thing.speed.value,
            den=document.thing.den.value,
            oIFrame=document.getElementById('i'),
            oFramedDoc = (typeof oIFrame.contentDocument != 'undefined')?
                oIFrame.contentDocument: // W3C way
                (typeof oIFrame.contentWindow != 'undefined')?
                    oIFrame.contentWindow.document: // Microsoft way
                    (typeof oIFrame.document != 'undefined')?
                        oIFrame.document: // Traditional way
                        null; // And no way.
        if(oFramedDoc != null){
            oFramedDoc.open();
            oFramedDoc.write('<applet code="Wave" width="300" height="150" alt="Wave applet" align="center" vspace="5"><param name="color1" value="'+ca+'"><param name="color2" value="'+cb+'"> <param name="frames" value="'+frames+'"> <param name="colors" value="'+cs+'"> <param name="neg" value="'+neg+'"> <param name="pos" value="'+pos+'"> <param name="speed" value="'+speed+'"> <param name="density" value="'+den+'"></applet>');
        }
    }
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #10
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    The error was specifically on the quotes:

    var ca="document.thing.coloraa.value";

    as what liorean fixed.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #11
    Regular Coder
    Join Date
    Jan 2004
    Location
    Port Huron, MI, U.S.A.
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Now I have like this:

    <script type="text/javascript">
    <!--hide
    function dip(){
    var
    ca=document.thing.coloraa.value,
    cb=document.thing.colorbby.value,
    frames=document.thing.frames.value,
    cs=document.thing.cs.value,
    neg=document.thing.neg.value,
    pos=document.thing.pos.value,
    speed=document.thing.speed.value,
    den=document.thing.den.value,
    oIFrame=document.getElementById('i'),
    oFramedDoc = (typeof oIFrame.contentDocument != 'undefined')?
    oIFrame.contentDocument: // W3C way
    (typeof oIFrame.contentWindow != 'undefined')?
    oIFrame.contentWindow.document: // Microsoft way
    (typeof oIFrame.document != 'undefined')?
    oIFrame.document: // Traditional way
    null; // And no way.
    if(oFramedDoc != null){
    oFramedDoc.open();
    oFramedDoc.write('<applet code="Wave" width="300" height="150" alt="Wave applet" align="center" vspace="5"><param name="color1" value="'+ca+'"><param name="color2" value="'+cb+'"> <param name="frames" value="'+frames+'"> <param name="colors" value="'+cs+'"> <param name="neg" value="'+neg+'"> <param name="pos" value="'+pos+'"> <param name="speed" value="'+speed+'"> <param name="density" value="'+den+'"></applet>');
    }
    }
    //-->
    </script>
    </head><body bgcolor=royalblue>
    <iframe ID="i" width=307 height=157></iframe>
    <form name="thing" onSubmit="dip()">
    <input type=text size=22 name="coloraa" value="color11">
    <input type=text size=22 name="colorbby" value="anutter color22">
    <input type=text size=22 name="frames" value="32">
    <input type=text size=22 name="cs" value="256">
    <input type=text size=22 name="neg" value="2">
    <input type=text size=22 name="pos" value="2">
    <input type=text size=22 name="speed" value="50">
    <input type=text size=22 name="den" value="100">
    <input type=submit value="Make Applet Happen" style="border-style:ridge" style="border color:blue" style="background-image:URL(g7.bmp)" style="color:aqua;font-weight:bold;font-style:italic">
    </form>

    ...and the iframe just comes up blank.

  • #12
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Don't forget the document.close()

    if(oFramedDoc != null){
    oFramedDoc.open();
    oFramedDoc.write('....');
    oFramedDoc.close();
    }
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #13
    Regular Coder
    Join Date
    Jan 2004
    Location
    Port Huron, MI, U.S.A.
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Geez... it still comes up blank. All the coding seems correct and I don't get an error. Everything should work...

  • #14
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    try putting html and body tags.

    if(oFramedDoc != null){
    oFramedDoc.open();
    oFramedDoc.write('<html><body><applet ....</applet></body></html>');
    oFramedDoc.close();
    }

    If it still fails, try removing the oFramedDoc.open() line as oFramedDoc.write() automatically calls it.

    BTW, what browser are you using? Does it have the required Java plugin installed? Does the applet work if the tags are hardcoded?
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #15
    Regular Coder
    Join Date
    Jan 2004
    Location
    Port Huron, MI, U.S.A.
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I tried the <HTML><BODY> thing with no success, so I'll try the oFramedDoc.open() and oFramedDoc.write() thing. I'm using a recent (not sure quite which) version of IE, that does support java. The applet works when it's hardcoded.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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