1

I have a problem with loading data into an < object > using Javascript. It refuses to work in Chrome, no error message either.

You can see a minimal example to play with here: http://tinkerbin.com/HIqG0ypb


submit button disappears

I try to send an email using php and a simple form. The code is uploaded: http://webofdreams.ro/tests/basic%20template.html The send email form is under sent to a friend. The problem is that the email is not sent and the submit button disappears after it was clicked. If there is another button (let's say cancel) after pressing cancel the code is run, but not email is sent. The code running on the server is as simple as it gets:

<?php

$mailTo = $_POST['emailTo'];
$mailFrom = $_POST['emailFrom'];
$name = $_POST['name'];
$message = 'Your friend ' . $name .  'recommends this Web site: ';
$subject = $name . 'recommends Fine Maid';


mail($mailTo, $subject, $message);
echo "Mail Sent.";
?>

Edit: html:

   <html>
                           <ul>
                                <li><a href="#" title="">Call us</a>
                                    <div class="navLinks"> </div>
                                </li>
                                <li><a href="#">Visit our website</a>
                                       <div class="navLinks"> Content Here </div>
                                </li>
                                <li><a href="#">Email us</a>
                                       <div class="navLinks"> Content Here </div>
                                </li>
                                <li><a href="#">Send to a friend</a>
                                       <div class="navLinks"> 
                                            <form name="send-to-friend" id="form2" method="post" action="sendemail.php">
                                                <label for="name" class="blockItem">Your Name</label>
                                                <input type="text" class="blockItem" id="name" name="name" maxlength="60" size="30"/>
                                                <label for="emailFrom" class="blockItem">Your Email</label>
                                                <input type="text" class="blockItem" id="emailFrom" name="emailFrom" maxlength="60" size="30" />
                                                <label for="emailTo" class="blockItem">Your friend's email</label>
                                                <input  type="text" class="blockItem" id="emailTo" name="emailTo" maxlength="60" size="30" value="" />             
                                                <input class="button" id="submit" type="submit" value="Send Message"/>
                                                <!--<input  class="button"  type="submit" value="Cancel"  />-->

                                            </form>
                                       </div>
                                </li>
                            </ul>
    </html>

CSS:

.nav ul {
   list-style-type:none;}
.nav {
    float: right;
    line-height: 3.3em;
    }
.nav li {
    margin: 0 .5em;
    display: inline-block;
    }
.nav li a {
    color: #000;
    font-size: 1.1em;
    }
.navLinks {
    position: absolute;
    top: 3em;
    background: #2C75D8;
    padding: 0 5px;
    border: 2px solid #94afd3;
    -moz-box-shadow: 0 0 4px #fff;
    -webkit-box-shadow: 0 0 4px #fff;
    box-shadow: 0 0 4px #bbb;
    -webkit-border-radius: 7px;
    -moz-border-radius: 7px;
    border-radius: 7px;
    z-index: 1000;
    }       
form {
    font-family: Tahoma, Geneva, sans-serif;
    font-size: 14px;
    line-height: 1.5em;
    color: #ddd;
    text-decoration: none;
    padding: 1em;
    margin-bottom: 1em; 
    }   
label {
    margin: 10px 0 0 0;
    }
.blockItem {
    display: block;
    }
.error {
    display: block;
    color: #FF8080;
    }
.button {
    display: inline;
    margin-top: 10px;
    }   
span {
    color: #F00;
    }

jquery:

    $(document).ready(function() {
        $('.commentContainer:odd').addClass('darker');

        $('#hideButton').click(function() {
        $(this).hide();     
        });

        $('.navLinks').hide();

        $(".nav a").on("click", function(e) {
            $(".navLinks").hide();
            $(this).siblings(".navLinks").show();
            e.preventDefault();
        });
});
4

1 に答える 1

0

ブラウザが object.data をURIとして設定できると想定しているのに、その URI で利用可能なコンテンツを表示するのは奇妙です。セキュリティ上の欠陥のように思えます: フレームを使用せずに完全なコンテンツがページに挿入される可能性があります。あなたの例のtest.comがwindow.parentまたはそのようなものにアクセスできるのだろうか

[編集]

そう

<script type="text/javascript">
  function openFrame() {
    document.getElementById('testFrame').data="http://test.com";
  }
</script>

Chrome では次のように記述する必要があります。

<script type="text/javascript">
  function openFrame() {
    document.getElementById('testFrame').data="http://test.com";
    var el = document.getElementById("testFrame");
    var h = el.innerHTML;
    el.innerHTML = h;
  }
</script>

ここで、testFrame は次のとおりです。

  <object id="testFrame" type="text/html" style="overflow-x: hidden; width: 100%; height: 100%" />
于 2012-06-28T13:18:52.330 に答える