作者 主題: 左框架開關問題  (閱讀 1987 次)

0 會員 與 1 訪客 正在閱讀本文。

dark

  • 俺是博士!
  • *****
  • 文章數: 1581
    • 檢視個人資料
左框架開關問題
« 於: 2013-02-07 16:48 »
底下為左右 frame , 左框架可開關
不同於一般所見的是
只有 2 個框架 , 並非中間藏一個小框架的方式

目的為了中間的框線可以隨機調整 (無 frame noresize)


目前遇到一個問題 ..
在 google chrome 中 , 經手動 resize 後 , 關閉關不緊 , 恢復的寬度也累加
不知 chrome 對 cols 參數的處理是否有所不同

還請高手們多多指點


ps:
因為這個框架想拿來隨意塞在 iframe
圖片 base64 塞入 ... 不是惡意程式


代碼: [選擇]
<?php

switch($_REQUEST['frame']){
case "right":
echo <<< MmYyRrEeMm
right
MmYyRrEeMm;
break;

case "rtjs":
echo <<< MmYyRrEeMm
function switchSysBarr(){
parent.document.getElementById("sumfrm").cols=document.getElementById("rtbar").alt;
document.getElementById("rtbar").style.display="none";
parent.lfFrame.document.getElementById('lfbar').style.display="";
}
MmYyRrEeMm;
break;

case "left":
$serverip=$_SERVER['SERVER_ADDR'];
$serverport=$_SERVER['SERVER_PORT'];
$serverphpf=$_SERVER['SCRIPT_NAME'];


echo <<< MmYyRrEeMm
<html><head><meta charset="big5" content="text/html;" http-equiv="Content-Type">
<script language="javascript">
function ckrejs(fm,url){

url=url.replace(/^.*\//g,'');
for(i=0;i<fm.scripts.length;i++){
tmpv=fm.scripts[i].src.replace(/^.*\//g,'')
if(tmpv==url){
// alert("src="+fm.scripts[i].src.replace(/^.*\//g,''));
// alert("url="+url.replace(/^.*\//g,''));
return false;
}
}
return true;
}
function switchSysBar(){
document.body.scrollWidth>=document.documentElement.clientWidth?sumfrmcolstmp=document.body.scrollWidth:sumfrmcolstmp=document.documentElement.clientWidth;
parent.rtFrame.document.body.scrollWidth>=parent.rtFrame.document.documentElement.clientWidth?sumfrmcolstmp2=parent.rtFrame.document.body.scrollWidth:sumfrmcolstmp2=parent.rtFrame.document.documentElement.clientWidth;
sumfrmcolstmp=Math.ceil((sumfrmcolstmp+1)/(sumfrmcolstmp+sumfrmcolstmp2+2)*100);
sumfrmcolstmp=sumfrmcolstmp+"%,"+(100-sumfrmcolstmp)+"%";

document.getElementById('lfbar').style.display="none";
parent.document.getElementById('sumfrm').cols="0%,100%";
// ie script 比對問題 if(ckrejs(parent.rtFrame.document,'http://
{$serverip}:{$serverport}{$serverphpf}?frame=rtjs')==true){
if(parent.rtFrame.document.getElementById('rtbar')==null){
//alert('addjs');
parent.rtFrame.document.body.innerHTML=parent.rtFrame.document.body.innerHTML+'<img id="rtbar" onclick="switchSysBarr()" height="57" border="0" width="9" style="position:absolute;top: 0px;left:0px;z-index: 1" alt="30%,70%" src="?frame=pico"/>';
var tmphead = parent.rtFrame.document.getElementsByTagName("head")[0]||parent.rtFrame.document.documentElement;
var tmpscript = parent.rtFrame.document.createElement("script");
tmpscript.type="text/javascript";
tmpscript.src="?frame=rtjs"
tmpscript.charset = "UTF-8";
tmphead.appendChild(tmpscript);
}else{
//alert('noaddjs');
parent.rtFrame.document.getElementById('rtbar').style.display="";
}
parent.rtFrame.document.getElementById('rtbar').alt=sumfrmcolstmp;
}

var sumfrmcols=parent.document.getElementById('sumfrm').cols;
var sumfrmcolstmp;
</script>
</head>
<img id="lfbar" onclick="switchSysBar()" height="57" border="0" width="9" style="position:absolute;top: 0px;right:0px" alt="" src="?frame=picc"/>

MmYyRrEeMm;
break;



case "pico":
header("Content-type:image/jpg");
$tmp_str='iVBORw0KGgoAAAANSUhEUgAAAAkAAAA5CAYAAADk6wG9AAAAAXNSR0IArs4c6QAAAARnQU1BAACx
jwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAADmSURBVEhL7ZY9CsJAEIW30RN4QEtLwdNYiQi2
4glE/ENSeAARwUILo2skWOaZZ1hZkmx+WBCELab7mDe82dkZIQYSedEcSnTXAeQzhOgfARWjEzA5
A7MrsPIjtJcv9DaBGdo9AO8WoTWOlUyZCB1CJKWkoeklkfshNPdryO2tCqeZSs4uE32qVbi946Vy
6qkU9k6H7CyoLPdXjgsBpJub6R0hhj4pRoggW0K3CyGCBEozEcj0TtWku52bSf9VSsfcPTo35hU2
gvtYv4uaI7U17WC1Xr07Ptuca1+Y7oJGfBd0Fsld8AYIQNBLAkb7+wAAAABJRU5ErkJggg==
'
;
echo base64_decode($tmp_str);
break;

case "picc":
header("Content-type:image/jpg");
/* $tmp_str='iVBORw0KGgoAAAANSUhEUgAAAAkAAAA5CAYAAADk6wG9AAAAAXNSR0IArs4c6QAAAARnQU1BAACx
jwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAADnSURBVEhL7VY7CsJAFNxGT+ABLS0FT2MlItiK
JxDxh6TwACKChRZG10iwzJjn8iDI/sIGIWCxpBneTOZ9hRhI6F5zKNFdJ5DPFKJ/BPiNTsDkDMyu
wCrO0F6+0NskZtDuAUS3DK1xzmSKRKBDCiXlGzS9KLofguZxCbp9kHAyk+nCIpFPpYSHO+6k41Kx
5q4ICrPAm66WjgvhaAQCWEEMoK82d0WAdyRuTm3unJqo3WmqOP+OQF417l0FVuFM5xw93nS1LLq/
435FV+2Wqn6wbk07mIVHd3y2Oa19YboLGvld0Fmou+ANM/XO4z7pfdIAAAAASUVORK5CYII=
';*/

$tmp_str='iVBORw0KGgoAAAANSUhEUgAAAAkAAAA5CAYAAADk6wG9AAAABGdBTUEAALGPC/xhBQAAAO5JREFU
SEtjfP/py//Ki38Z5t77x/D7HwN2UHDs4/+EI9/+n373///+1///b3z+///iR///z7yPwAwiy97/
P/n23//zHyCK1j/Doohh/vv/d7/8J17RwTc4rEM3CaubSFZEuXW3ob4DmUSdIMAZ4iDfwawbDfH/
wzvEYSmTgQEt3yGncZAikAKsimBJBaYAp0nICvBaR9AkWFmA003IZQEoB+O1Dm9GQDcJo3xCDyfK
CozRbI5SjhMMzAEoWHG6CbnMpIPDSUqZRKdxrHULqA4+TagOLj4Oqc2PvvmHu6IGtQtA1T7bwvf/
QTkHGwYAiMG/7Ca9i9wAAAAASUVORK5CYII=
'
;
echo base64_decode($tmp_str);
break;

case "picp":
header("Content-type:image/jpg");
$tmp_str='R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';
echo base64_decode($tmp_str);
break;


default:
echo <<< MmYyRrEeMm
<frameset id="sumfrm" framespacing="0" border="2" frameborder="2" cols="20%,80%" rows="*">
<frame name="lfFrame" id="lffm" src="?frame=left" scrolling="auto" frameborder="1"></frame>
<frame name="rtFrame" id="rtfm" src="?frame=right" scrolling="auto" frameborder="1"></frame>
</frameset>
MmYyRrEeMm;
}


?>



dark

  • 俺是博士!
  • *****
  • 文章數: 1581
    • 檢視個人資料
Re: 左框架開關問題
« 回覆 #1 於: 2013-02-18 13:36 »
上網查的答案是 ..
chrome 原本的 bug , 且好幾年來一直存在
... 那就是不打算修了吧


原本思考著將 .. 舊的 frame  , resize , 新的比例都紀錄 , 動作前還原手動 resize 動作
但這些動作 chrome 都聰明的把它整合成一個動作 (?? ... 猜想)

總之 , 最後解法是 ..
cols="";
setTimeout('cols=new%',0);

(第一次縮放會有小誤差, 因為左右視窗比例是取整數算的 , 加上框線會影響)

代碼: [選擇]
<?php

switch($_REQUEST['frame']){
case "right":
echo <<< MmYyRrEeMm
right
MmYyRrEeMm;
break;

case "rtjs":
echo <<< MmYyRrEeMm
function switchSysBarr(){
parent.document.getElementById("sumfrm").cols=document.getElementById("rtbar").alt;
document.getElementById("rtbar").style.display="none";
parent.lfFrame.document.getElementById('lfbar').style.display="";
}
MmYyRrEeMm;
break;

case "left":
$serverip=$_SERVER['SERVER_ADDR'];
$serverport=$_SERVER['SERVER_PORT'];
$serverphpf=$_SERVER['SCRIPT_NAME'];


echo <<< MmYyRrEeMm
<html><head><meta charset="big5" content="text/html;" http-equiv="Content-Type">
<script language="javascript">
function ckrejs(fm,url){

url=url.replace(/^.*\//g,'');
for(i=0;i<fm.scripts.length;i++){
tmpv=fm.scripts[i].src.replace(/^.*\//g,'')
if(tmpv==url){
// alert("src="+fm.scripts[i].src.replace(/^.*\//g,''));
// alert("url="+url.replace(/^.*\//g,''));
return false;
}
}
return true;
}
function switchSysBar(){

document.body.scrollWidth>=document.documentElement.clientWidth?sumfrmcolstmp=document.body.scrollWidth:sumfrmcolstmp=document.documentElement.clientWidth;
parent.rtFrame.document.body.scrollWidth>=parent.rtFrame.document.documentElement.clientWidth?sumfrmcolstmp2=parent.rtFrame.document.body.scrollWidth:sumfrmcolstmp2=parent.rtFrame.document.documentElement.clientWidth;
sumfrmcolstmp=Math.ceil((sumfrmcolstmp+1)/(sumfrmcolstmp+sumfrmcolstmp2+2)*100);
sumfrmcolstmp=sumfrmcolstmp+"%,"+(100-sumfrmcolstmp)+"%";

parent.document.getElementById('sumfrm').cols="";
document.getElementById('lfbar').style.display="none";

// ie script 比對問題 if(ckrejs(parent.rtFrame.document,'http://
{$serverip}:{$serverport}{$serverphpf}?frame=rtjs')==true){
if(parent.rtFrame.document.getElementById('rtbar')==null){
//alert('addjs');
parent.rtFrame.document.body.innerHTML=parent.rtFrame.document.body.innerHTML+'<img id="rtbar" onclick="switchSysBarr()" height="57" border="0" width="9" style="position:absolute;top: 0px;left:0px;z-index: 1" alt="20%,80%" src="?frame=pico"/>';
var tmphead = parent.rtFrame.document.getElementsByTagName("head")[0]||parent.rtFrame.document.documentElement;
var tmpscript = parent.rtFrame.document.createElement("script");
tmpscript.type="text/javascript";
tmpscript.src="?frame=rtjs"
tmpscript.charset = "UTF-8";
tmphead.appendChild(tmpscript);
}else{
//alert('noaddjs');
parent.rtFrame.document.getElementById('rtbar').style.display="";
}

parent.rtFrame.document.getElementById('rtbar').alt=sumfrmcolstmp;
setTimeout('parent.document.getElementById("sumfrm").cols="0,*"',0);
}

</script>
</head>
<img id="lfbar" onclick="switchSysBar()" height="57" border="0" width="9" style="position:absolute;top: 0px;right:0px" alt="" src="?frame=picc"/>

MmYyRrEeMm;
break;



case "pico":
header("Content-type:image/jpg");
$tmp_str='iVBORw0KGgoAAAANSUhEUgAAAAkAAAA5CAYAAADk6wG9AAAAAXNSR0IArs4c6QAAAARnQU1BAACx
jwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAADmSURBVEhL7ZY9CsJAEIW30RN4QEtLwdNYiQi2
4glE/ENSeAARwUILo2skWOaZZ1hZkmx+WBCELab7mDe82dkZIQYSedEcSnTXAeQzhOgfARWjEzA5
A7MrsPIjtJcv9DaBGdo9AO8WoTWOlUyZCB1CJKWkoeklkfshNPdryO2tCqeZSs4uE32qVbi946Vy
6qkU9k6H7CyoLPdXjgsBpJub6R0hhj4pRoggW0K3CyGCBEozEcj0TtWku52bSf9VSsfcPTo35hU2
gvtYv4uaI7U17WC1Xr07Ptuca1+Y7oJGfBd0Fsld8AYIQNBLAkb7+wAAAABJRU5ErkJggg==
'
;
echo base64_decode($tmp_str);
break;

case "picc":
header("Content-type:image/jpg");
$tmp_str='iVBORw0KGgoAAAANSUhEUgAAAAkAAAA5CAYAAADk6wG9AAAABGdBTUEAALGPC/xhBQAAAO5JREFU
SEtjfP/py//Ki38Z5t77x/D7HwN2UHDs4/+EI9/+n373///+1///b3z+///iR///z7yPwAwiy97/
P/n23//zHyCK1j/Doohh/vv/d7/8J17RwTc4rEM3CaubSFZEuXW3ob4DmUSdIMAZ4iDfwawbDfH/
wzvEYSmTgQEt3yGncZAikAKsimBJBaYAp0nICvBaR9AkWFmA003IZQEoB+O1Dm9GQDcJo3xCDyfK
CozRbI5SjhMMzAEoWHG6CbnMpIPDSUqZRKdxrHULqA4+TagOLj4Oqc2PvvmHu6IGtQtA1T7bwvf/
QTkHGwYAiMG/7Ca9i9wAAAAASUVORK5CYII=
'
;
echo base64_decode($tmp_str);
break;

case "picp":
header("Content-type:image/jpg");
$tmp_str='R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';
echo base64_decode($tmp_str);
break;


default:
echo <<< MmYyRrEeMm
<frameset id="sumfrm" framespacing="0" border="2" frameborder="2" cols="20%,80%" rows="*">
<frame name="lfFrame" id="lffm" src="?frame=left" scrolling="auto" frameborder="1" style="border-right: 0px solid #FFFFFF;"></frame>
<frame name="rtFrame" id="rtfm" src="?frame=right" scrolling="auto" frameborder="1" style="border-left: 0px solid #FFFFFF;"></frame>
</frameset>
MmYyRrEeMm;
}

?>