firefox不尊重javascript改变浮动方向 [英] firefox doesn't respect javascript change of float direction

查看:165
本文介绍了firefox不尊重javascript改变浮动方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此代码适用于所有主要的浏览器,除了firefox,说它已经做了我问,但它不。这让我疯狂。这是完整的html,css和javascript:

This code works in all the major browsers except firefox which says it has done what I ask, but it doesn't. It's driving me crazy. This is the full html, css and javascript:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" >
<html>
<head>
<style type=text/css>
.CastPic
{
    position        :   relative;
    top     :   +0px;
    width       :   250px; 
    height  :   250px; 
    padding-top     :   25px;
    padding-left        :   25px;
    padding-right       :   25px;
    padding-bottom      :   25px;
    background-image        :   url('Cast photos/Fiona Colquhoun.jpg');
    background-color        :   ivory;
    background-repeat       :   no-repeat;
    background-position     :   center; 
    cursor          :   pointer;
    border-style        :   solid;
    border-width        :   12px;
    border-color        :   green;
    float           :   left;
}
</style>
<script language="JavaScript" type="text/JavaScript">
function toggle()
{
if (document.getElementById("CastPic").style.float =="right")
{
    document.myForm.msg.value = "float is right"
    document.getElementById("CastPic").style.float="left"
    document.getElementById("CastPic").style.borderColor="red"
}
else
{
    document.myForm.msg.value = "float is left"
    document.getElementById("CastPic").style.float="right"
    document.getElementById("CastPic").style.borderColor="blue"
}
document.myForm.msg.value = 'float is now ' + document.getElementById("CastPic").style.float
}
</script>
</head>
<body>
<div class="CastPic" id="CastPic"></div>
<form name="myForm" enctype="application/x-www-form-urlencoded"> 
<input type="text"   name="msg" value=""  size=65>
<input type="button" value="Switch"  onClick="toggle()">
</form>
</body>
</html>

这当然只是一个测试脚本 - 我提取这个位只是为了看是否有什么影响。我看不到任何内容。

This is of course only a test script - I extracted this bit just to see if anything else affected it. I can't see anything.

Tia
Adrian

Tia Adrian

推荐答案

http://www.iamseree.com/application-development/use -javascript-to-change-float-style

document.getElementById("CastPic").style.cssFloat="left" 

代码提醒!!

这篇关于firefox不尊重javascript改变浮动方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆