SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Nov 2002
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Spellchecking pop-up woes :)

    Hi all,

    I'm trying to use a script developed as a spell checker for vBulletin forums. The original developer did a big no-no by putting <form> and <frameset> code in the same page. IE will parse it as expected, however other more standards-compliant browsers, such as Opera and Netscape, will not.

    W3C says <form> elements cannot appear on a page with <frameset>s.

    Here's the current script as it stands:

    PHP Code:
    <?php
    if (!isset($action) || $action=='') {
    ?><html>
    <head>
    <title>Spell Checker</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript">
    <!--
    function submitforms() {
      document.submitcheckform.checktext.value = window.opener.ftext.value;
      document.submitcheckform.submit();
    }
    //-->
    </script>
    </head>
    <form name="submitcheckform" action="spellcheck.php" method="POST" target="checkFrame">
    <input type="hidden" name="action" value="check">
    <input type="hidden" name="checktext" value="<?=htmlentities(stripslashes($checktext))?>">
    </form>

    <frameset rows="*,150" frameborder="NO" border="0" framespacing="0" onload="submitforms()">
     <frame name="checkFrame" scrolling="AUTO" noresize src="blank.html" >
     <frame name="suggFrame" src="blank.html" scrolling="NO" noresize>
    </frameset>
    </html>
    <?php } else { ?>
    <html>
    <head>
    <title>Spell Checker</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript">
    <!--
    function submitforms() {
      document.submitcheckform.submit();
    }
    //-->
    </script>
    </head>

    <form name="submitcheckform" action="check.php" method="POST" target="checkFrame">
    <input type="hidden" name="action" value="check">
    <input type="hidden" name="checktext" value="<?=htmlentities(stripslashes($checktext))?>">
    </form>

    <frameset rows="*,150" frameborder="NO" border="0" framespacing="0" onload="submitforms()"> 
     <frame name="checkFrame" scrolling="AUTO" noresize src="blank.html" >
     <frame name="suggFrame" src="blank.html" scrolling="NO" noresize>
    </frameset><noframes></noframes>
    </html>
    <?php
    }
    ?>
    Where $checktext is the text being passed to the checker.

    My initial thought was to move the <form> code to a third "hidden" frameset called "formcode". I took out the <form> stuff from the output of the spell check script and created formcode.php:

    PHP Code:
    <?php $checktext urldecode($ct); ?>
    <html>
    <head>
    <script language="JavaScript">
    <!--
    function getchecktext() {
      document.submitcheckform.checktext.value = parent.document.checktext;
      document.submitcheckformnew.checktext.value = parent.document.checktext;
    }
    //-->
    </script>
    </head>
    <body onload="getchecktext();">
    <form name="submitcheckform" action="spellcheck-beta.php" method="POST" target="checkFrame">
    <input type="hidden" name="action" value="check">
    <input type="hidden" name="checktext" value="<?=$checktext?>">
    </form>
    <form name="submitcheckformnew" action="check.php" method="POST" target="checkFrame">
    <input type="hidden" name="action" value="check">
    <input type="hidden" name="checktext" value="<?=$checktext?>">
    </form>
    </body></html>
    and changed the javascript in spellcheck-beta.php to:

    Code:
    <script language="JavaScript">
    <!--
    function submitforms() {
      var checktext = window.opener.ftext.value;
      parent.formcode.document.submitcheckform.checktext.value = window.opener.ftext.value;
      parent.formcode.document.submitcheckform.submit();
    }
    //-->
    </script>
    The problem here is that the text to be checked is not being picked up by formcode.php. It was my impression that " parent.formcode.document.submitcheckform.checktext.value = window.opener.ftext.value;" would set the value of checktext in the formcode.php forms.

    What am I missing here?

    Thanks,
    Paul

  2. #2
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Well... If you look at the original code the user will be getting either the form or the frameset. They shouldn't be getting both because they are in different branches of the PHP if/else statement.

    Maybe a URL with the problem would help. It would also be nice if you have a test user setup so people can test and evaluate. Reading code is one thing but running it brings a lot more to light, especially with errors and visual feedback.
    Wayne Luke
    ------------


  3. #3
    SitePoint Member
    Join Date
    Nov 2002
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Wayne,

    Thanks for the really fast response!

    There are two separate html documents being spit out by the php script... If you look closely, you'll see that both the if and else statement have complete html docs.

    For example, the entire code of the if statement is:

    Code:
    <html>
    <head>
    <title>Spell Checker</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script language="JavaScript">
    <!--
    function submitforms() {
      document.submitcheckform.checktext.value = window.opener.ftext.value;
      document.submitcheckform.submit();
    }
    //-->
    </script>
    </head>
    <form name="submitcheckform" action="spellcheck.php" method="POST" target="checkFrame">
    <input type="hidden" name="action" value="check">
    <input type="hidden" name="checktext" value="<?=htmlentities(stripslashes($checktext))?>">
    </form>
    
    <frameset rows="*,150" frameborder="NO" border="0" framespacing="0" onload="submitforms()">
     <frame name="checkFrame" scrolling="AUTO" noresize src="blank.html" >
     <frame name="suggFrame" src="blank.html" scrolling="NO" noresize>
    </frameset>
    </html>
    Which has both the <frameset> and the <form>.

    Thanks for the suggestion about setting up a test site/test user.

    To test this out, visit http://www.loveshack.org/forums/newr...threadid=18285 .. A test user account is not required as we allow guests to post.

    I wish the original author of this script (who I assume knows more javascript than I) had the time to debug this.

    Edit: Removed outdated info.
    Last edited by Paul E; Nov 5, 2002 at 23:58.

  4. #4
    SitePoint Member
    Join Date
    Nov 2002
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't suppose anyone has had a chance to look at this

  5. #5
    Your Lord and Master, Foamy gold trophy Hierophant's Avatar
    Join Date
    Aug 1999
    Location
    Lancaster, Ca. USA
    Posts
    12,305
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Works just fine in Mozilla 1.0 for me.
    Wayne Luke
    ------------


  6. #6
    SitePoint Member
    Join Date
    Nov 2002
    Posts
    4
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Wayne,

    Thanks for the info! After much tinkering and searching the web for tidbits of javascript info, I was able to get it to work with both the latest versions of Netscape and Internet Explorer and not burp (literally just minutes ago, too--what great timing!). Opera didn't work out so nicely, but I think at this point I can live with that.

    I'll package up the changes I've made and post it on phpspellchecker thread over at vbulletin.org. Perhaps some kind-hearted soul with a solid knowledge of javascript could make this pieced together mess work a little more efficiently.

    Thanks again for all your help!
    Paul


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
  •