Ask Question Forum:
C
O
M
P
U
T
E
R
2
8
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Y-position of the mouse cursor
Attachment:===
Body align to second frame in javascript

re-direct URL web page based on the input product NO in the input box in the first frame
We call second frame wiht its id="Frame1"
I get two questions, hopeyou can hlep
Question-1 I would like to know how to change second iframe's body margin that will align to most top,left, right,
botton to its frame(I mean second frame), I try my code but it is failed, please view the code
I use Html-DOM to acces second frame body, but it fail like
document.getElementById("frame1").document.body.style.marginTop='0';
document.getElementById("frame1").document.body.style.marginLeft='0';
Question-2, Since the second frame will redirect to Excel's htm webpage
and its htm name is based on the product No in the input box, I could not get rid of the scroll bar
of the second frame even I try two way to fix this but fail. How to combine both
frame's scroll bar as one ?
1- <iframe height="700" marigin="0" width="1400" scrolling="no" border="0px" id="frame1" src="http://www.website.com/index.htm">
scrolling="NO" is not response at all
2_ ANd try this document.getElementById("frame1").document.body.style.overflow='hidden';
that is also no any response
Please view my image you will know my question2
It seems I do anything that is no any response , Please advise
Duncan
!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><style type="text/css">* {font-size:15px;font-family:Tahoma, Arial, 'Trebuchet MS', Verdana;}html,body {background-color: #4169e1 ;margin:1px;padding:0;height:100%;}</style><script type="text/javascript">// e - event, el - element, fn- callback functionfunction checkEnter(e, el,fn) { var key=e.keyCode || e.which; if (key==13){ fn();el.value='';document.getElementById("frame1").document.body.style.overflow='hidden';document.getElementById("frame1").document.body.style.marginTop='0';document.getElementById("frame1").document.body.style.marginLeft='0';document.getElementById("frame1").document.body.style.marginBottom='0';document.getElementById("frame1").document.body.style.marginRight='0';return false; } return true;}function formSubmit() { var my_val = document.getElementById('text1').value; // check if value is empty if ( my_val.length > 0) { document.getElementById("frame1").src="http://www.mywebiste.com/"+ my_val +".htm"; }}</script></HEAD><body><input style="width: 100px; height: 20px;font-size:16pt;" size="12" type="text" name="text1" id="text1" value=0 onclick="this.value=''; this.className='highlighted'" onblur="if(this.value=='')this.value=this.defaultValue; this.className=''"onkeydown="return checkEnter(event, this,formSubmit);" ><input type="button" value="submit" onclick="formSubmit();" /><iframe height="700" marigin="0" width="1400" scrolling="no" border="0px" id="frame1" src="http://www.website.com/index.htm"></body></HTML>
1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50:51:52:53:54:55:56:57:58:59:60:61:62:63:
Attachment:Snap16.jpgSnap20.jpg
it seems margin issue is fixed and can be controlled and no need edit in excel htm file.
For Scroll bar , since at the beginning I am using iframe that might be issue since Excel sheet is using <frame>
and finally frame is ok to control scroll bar disable.
using
Thanks for your reply
Duncan
I attach a new version of onkeydown.html
For the point 2:
i change in the style:
height:95%;
and in SetSize javascript function
document.getElementById("frame1").height=document.body.offsetHeight-30;
with this, only will appear one scrollbar
I tested it on IE8 and Firefox, in IE6 appear the vertical scrollbar but disabled
For the point 1:
I tried change the bgcolor of 66666.htm, but did not work.
You could do try it changing it, but 66666.htm has too a frameset
to avoid double scroll bar ? If input box can be iframe, it can go anywhere in
the webpage
The only improvement is that you told the margin problem in question-1 is better in Firefox but not in IE
Please advise, it seems we should use frame and framset instead of iframe. Actully what is major diffferent
if we want actually solve the issues?
the image as attached
For question-1, I tried it is better onMozilla Firefox green color frame is merged into blue frame that is what you said Excel already
take of this. But in my IE7, it is same as before no any change.
For question, After adding setsize with three different ways, the result is same as before no matter in Firefox or IE7
1-
//document.getElementById("frame1").height=document.body.scrollHeight-10;
//document.getElementById("frame1").width=document.body.scrollWidth-10;
document.getElementById("frame1").height=document.body.offsetHeight-10;
document.getElementById("frame1").width=document.body.offsetWidth-10;
2-
document.getElementById("frame1").height=document.body.scrollHeight-10;
document.getElementById("frame1").width=document.body.scrollWidth-10;
//document.getElementById("frame1").height=document.body.offsetHeight-10;
//document.getElementById("frame1").width=document.body.offsetWidth-10;
3-
document.getElementById("frame1").height=document.body.scrollHeight-10;
document.getElementById("frame1").width=document.body.scrollWidth-10;
document.getElementById("frame1").height=document.body.offsetHeight-10;
document.getElementById("frame1").width=document.body.offsetWidth-10;
Please advise, do you have IE7, could you try it at your side
For first question, you mean I don't need to do anything because excel will take care
and for second question, after I run your html, I could "NOT"redirect the page. Is it because
setsize() block the redirect. I already setup correct path .
document.getElementById("frame1").src="file:///D:/mydirectory/"+ my_val +".htm";
and for second question, after I run your html, I could redirect the page. Is it because
setsize() block the redirect. I already setup correct path .
document.getElementById("frame1").src="file:///D:/mydirectory/"+ my_val +".htm";
Please advise
The "margin" is done in tables in te excel process conversion
on lines:
"<tr><td colspan=6 height=1 bgcolor="+c_rgszClr[2]+"></td></tr>"+
"<tr><td style="font:1pt"> <td>"+
If you want avoid double scrollbars, the best way is make the iframe with a less eight and width than the current IE6 window
you can do it with this lines:
document.getElementById("frame1").height=document.body.offsetHeight-10;
document.getElementById("frame1").width=document.body.offsetWidth-10;
I attach onkeydown.html with these changes
Added
on iframe tag
Added
<script type="text/javascript">function setSize(){//document.getElementById("frame1").height=document.body.scrollHeight-10;//document.getElementById("frame1").width=document.body.scrollWidth-10;document.getElementById("frame1").height=document.body.offsetHeight-10;document.getElementById("frame1").width=document.body.offsetWidth-10;}</script>
1:2:3:4:5:6:7:8:9:
After body tag
it seems margin issue is fixed and can be controlled and no need edit in excel htm file.
For Scroll bar , since at the beginning I am using iframe that might be issue since Excel sheet is using <frame>
and finally frame is ok to control scroll bar disable.
using
Thanks for your reply
Duncan
Please download the new 6666.xls again since the previous one data is too small, we could not see
the problem. I add more data row and col in the xls so you see the scroll bar in the second frame .
Download onkeydown.html and convert 66666.xls to 66666.htm in Excel which
also generate 66666.files to store all sheet.htm.
Step-2
Please change the "file:///D:/yourdirectory/" in onkeydown.html for your directory which store 66666.htm or 66666.xls
function formSubmit() {
var my_val = document.getElementById('text1').value;
// check if value is empty
if ( my_val.length > 0) {
document.getElementById("frame1").src="file:///D:/yourdirectory/"+ my_val +".htm";
}
}
Step 3-
At input box when onkeydown.html is in IE window and type 66666 and it will redirect to
"file:///D:/yourdirectory/66666.htm"
Please help and advise
post here all the files (individualle) you are using actually, and i can help you fixing it.
Just load the page and then go to
Tools / Error Console
error and input enter key could not make redirect URL
document.getElementByI("frame1").contentWindow.document.body.style.overflow:'auto';
if overflow='auto', it is back to normal but display no change
For these two, everything is same as before
document.getElementById("frame1").contentWindow.document.body.style.marginTop='0';
document.getElementById("frame1").contentWindow.document.body.style.marginLeft='0';
Do you thin free website for javascritp debugger software
document.getElementById("frame1").contentWindow.document.body.style.marginLeft='0';
document.getElementById("frame1").contentWindow.document.body.style.overflow:'auto';
If you get javascript error on these lines, please send te error, and the navigator app name and version
Display result is same as before for 1 & 2
At 2, I try =
document.getElementById("frame1").contentWindow.document.body.style:auto ' failed, same as before
document.getElementById("frame1").contentWindow.document.body.style='auto' ' failed same as before
document.getElementById("frame1").document.body.style:auto ' failed , same as before
document.getElementById("frame1").document.body.style='auto' ' failed, same as before
So you will see why scroll="0" is not working in <iframe height="700" marigin="0" width="1400" scrolling="no" border="0px" id="frame1" src="http://www.website.com/index.htm">
So I go directly to 1000.htm page that is generated by Excel saveas htm file, I know ther is frameset inside( please also
view part of 1000.htm code attached in code area"), You can find frameset, and if I put scrolling=no in this
"<frame src=""+document.all.item("shLink")[0].href+"" name="frSheet" noresize >"+ ,,, scroll bar is gone and no show
WHy ?
function fnBuildFrameset()
{
var szHTML="<frameset rows="*,18" border=0 width=0 frameborder=no framespacing=0>"+
"<frame src=""+document.all.item("shLink")[0].href+"" name="frSheet" noresize >"+
"<frameset cols="54,*" border=0 width=0 frameborder=no framespacing=0>"+
"<frame src="" name="frScroll" marginwidth=0 marginheight=0 scrolling=no>"+
"<frame src="" name="frTabs" marginwidth=0 marginheight=0 scrolling=no>"+
"</frameset></frameset><plaintext>";
<html xmlns:v="urn:schemas-microsoft-com:vml"xmlns:o="urn:schemas-microsoft-com:office:office"xmlns:x="urn:schemas-microsoft-com:office:excel"xmlns="http://www.w3.org/TR/REC-html40"><head><meta name="Excel Workbook Frameset"><meta http-equiv=Content-Type content="text/html; charset=big5"><meta name=ProgId content=Excel.Sheet><meta name=Generator content="Microsoft Excel 11"><link rel=File-List href="1000.files/filelist.xml"><link rel=Edit-Time-Data href="1000.files/editdata.mso"><link rel=OLE-Object-Data href="1000.files/oledata.mso"><!--[if gte mso 9]><xml> <o:DocumentProperties> <o:Author>kkw</o:Author> <o:LastAuthor>kkw</o:LastAuthor> <o:Created>2010-11-06T19:15:01Z</o:Created> <o:LastSaved>2010-11-12T18:45:49Z</o:LastSaved> <o:Version>11.9999</o:Version> </o:DocumentProperties> <o:OfficeDocumentSettings> <o:Colors> <o:Color> <o:Index>14</o:Index> <o:RGB>#DDDDDD</o:RGB> </o:Color> </o:Colors> </o:OfficeDocumentSettings></xml><![endif]--><![if !supportTabStrip]><link id="shLink" href="1000.files/sheet001.htm"><link id="shLink" href="1000.files/sheet002.htm"><link id="shLink"><script language="JavaScript"><!-- var c_lTabs=2; var c_rgszSh=new Array(c_lTabs); c_rgszSh[0] = "Daily13"; c_rgszSh[1] = "Intra13"; var c_rgszClr=new Array(8); c_rgszClr[0]="window"; c_rgszClr[1]="buttonface"; c_rgszClr[2]="windowframe"; c_rgszClr[3]="windowtext"; c_rgszClr[4]="threedlightshadow"; c_rgszClr[5]="threedhighlight"; c_rgszClr[6]="threeddarkshadow"; c_rgszClr[7]="threedshadow"; var g_iShCur; var g_rglTabX=new Array(c_lTabs);function fnGetIEVer(){ var ua=window.navigator.userAgent var msie=ua.indexOf("MSIE") if (msie>0 && window.navigator.platform=="Win32") return parseInt(ua.substring(msie+5,ua.indexOf(".", msie))); else return 0;}function fnBuildFrameset(){ var szHTML="<frameset rows="*,18" border=0 width=0 frameborder=no framespacing=0>"+ "<frame src=""+document.all.item("shLink")[0].href+"" name="frSheet" noresize >"+ "<frameset cols="54,*" border=0 width=0 frameborder=no framespacing=0>"+ "<frame src="" name="frScroll" marginwidth=0 marginheight=0 scrolling=no>"+ "<frame src="" name="frTabs" marginwidth=0 marginheight=0 scrolling=no>"+ "</frameset></frameset><plaintext>"; with (document) { open("text/html","replace"); write(szHTML); close(); } fnBuildTabStrip();}function fnBuildTabStrip(){ var szHTML= "<html><head><style>.clScroll {font:8pt Courier New;color:"+c_rgszClr[6]+";cursor:default;line-height:10pt;}"+ ".clScroll2 {font:10pt Arial;color:"+c_rgszClr[6]+";cursor:default;line-height:11pt;}</style></head>"+ "<body onclick="event.returnValue=false;" ondragstart="event.returnValue=false;" onselectstart="event.returnValue=false;" bgcolor="+c_rgszClr[4]+" topmargin=0 leftmargin=0><table cellpadding=0 cellspacing=0 width=100%>"+ "<tr><td colspan=6 height=1 bgcolor="+c_rgszClr[2]+"></td></tr>"+ "<tr><td style="font:1pt"> <td>"+ "<td valign=top id=tdScroll class="clScroll" onclick="parent.fnFastScrollTabs(0);" onmouseover="parent.fnMouseOverScroll(0);" onmouseout="parent.fnMouseOutScroll(0);"><a>«</a></td>"+ "<td valign=top id=tdScroll class="clScroll2" onclick="parent.fnScrollTabs(0);" ondblclick="parent.fnScrollTabs(0);" onmouseover="parent.fnMouseOverScroll(1);" onmouseout="parent.fnMouseOutScroll(1);"><a><</a></td>"+ "<td valign=top id=tdScroll class="clScroll2" onclick="parent.fnScrollTabs(1);" ondblclick="parent.fnScrollTabs(1);" onmouseover="parent.fnMouseOverScroll(2);" onmouseout="parent.fnMouseOutScroll(2);"><a>></a></td>"+ "<td valign=top id=tdScroll class="clScroll" onclick="parent.fnFastScrollTabs(1);" onmouseover="parent.fnMouseOverScroll(3);" onmouseout="parent.fnMouseOutScroll(3);"><a>»</a></td>"+ "<td style="font:1pt"> <td></tr></table></body></html>"; with (frames['frScroll'].document) { open("text/html","replace"); write(szHTML); close(); } szHTML = "<html><head>"+ "<style>A:link,A:visited,A:active {text-decoration:none;"+"color:"+c_rgszClr[3]+";}"+ ".clTab {cursor:hand;background:"+c_rgszClr[1]+";font:9pt ¿¿¿¿;padding-left:3px;padding-right:3px;text-align:center;}"+ ".clBorder {background:"+c_rgszClr[2]+";font:1pt;}"+ "</style></head><body onload="parent.fnInit();" onselectstart="event.returnValue=false;" ondragstart="event.returnValue=false;" bgcolor="+c_rgszClr[4]+ " topmargin=0 leftmargin=0><table id=tbTabs cellpadding=0 cellspacing=0>"; var iCellCount=(c_lTabs+1)*2; var i; for (i=0;i<iCellCount;i+=2) szHTML+="<col width=1><col>"; var iRow; for (iRow=0;iRow<6;iRow++) { szHTML+="<tr>"; if (iRow==5) szHTML+="<td colspan="+iCellCount+"></td>"; else { if (iRow==0) { for(i=0;i<iCellCount;i++) szHTML+="<td height=1 class="clBorder"></td>"; } else if (iRow==1) { for(i=0;i<c_lTabs;i++) { szHTML+="<td height=1 nowrap class="clBorder"> </td>"; szHTML+= "<td id=tdTab height=1 nowrap class="clTab" onmouseover="parent.fnMouseOverTab("+i+");" onmouseout="parent.fnMouseOutTab("+i+");">"+ "<a href=""+document.all.item("shLink")[i].href+"" target="frSheet" id=aTab> "+c_rgszSh[i]+" </a></td>"; } szHTML+="<td id=tdTab height=1 nowrap class="clBorder"><a id=aTab> </a></td><td width=100%></td>"; } else if (iRow==2) { for (i=0;i<c_lTabs;i++) szHTML+="<td height=1></td><td height=1 class="clBorder"></td>"; szHTML+="<td height=1></td><td height=1></td>"; } else if (iRow==3) { for (i=0;i<iCellCount;i++) szHTML+="<td height=1></td>"; } else if (iRow==4) { for (i=0;i<c_lTabs;i++) szHTML+="<td height=1 width=1></td><td height=1></td>"; szHTML+="<td height=1 width=1></td><td></td>"; } } szHTML+="</tr>"; } szHTML+="</table></body></html>"; with (frames['frTabs'].document) { open("text/html","replace"); charset=document.charset; write(szHTML); close(); }}function fnInit(){ g_rglTabX[0]=0; var i; for (i=1;i<=c_lTabs;i++) with (frames['frTabs'].document.all.tbTabs.rows[1].cells[fnTabToCol(i-1)]) g_rglTabX[i]=offsetLeft+offsetWidth-6;}function fnTabToCol(iTab){ return 2*iTab+1;}function fnNextTab(fDir){ var iNextTab=-1; var i; with (frames['frTabs'].document.body) { if (fDir==0) { if (scrollLeft>0) { for (i=0;i<c_lTabs&&g_rglTabX[i]<scrollLeft;i++); if (i<c_lTabs) iNextTab=i-1; } } else { if (g_rglTabX[c_lTabs]+6>offsetWidth+scrollLeft) { for (i=0;i<c_lTabs&&g_rglTabX[i]<=scrollLeft;i++); if (i<c_lTabs) iNextTab=i; } } } return iNextTab;}function fnScrollTabs(fDir){ var iNextTab=fnNextTab(fDir); if (iNextTab>=0) { frames['frTabs'].scroll(g_rglTabX[iNextTab],0); return true; } else return false;}function fnFastScrollTabs(fDir){ if (c_lTabs>16) frames['frTabs'].scroll(g_rglTabX[fDir?c_lTabs-1:0],0); else if (fnScrollTabs(fDir)>0) window.setTimeout("fnFastScrollTabs("+fDir+");",5);}function fnSetTabProps(iTab,fActive){ var iCol=fnTabToCol(iTab); var i; if (iTab>=0) { with (frames['frTabs'].document.all) { with (tbTabs) { for (i=0;i<=4;i++) { with (rows[i]) { if (i==0) cells[iCol].style.background=c_rgszClr[fActive?0:2]; else if (i>0 && i<4) { if (fActive) { cells[iCol-1].style.background=c_rgszClr[2]; cells[iCol].style.background=c_rgszClr[0]; cells[iCol+1].style.background=c_rgszClr[2]; } else { if (i==1) { cells[iCol-1].style.background=c_rgszClr[2]; cells[iCol].style.background=c_rgszClr[1]; cells[iCol+1].style.background=c_rgszClr[2]; } else { cells[iCol-1].style.background=c_rgszClr[4]; cells[iCol].style.background=c_rgszClr[(i==2)?2:4]; cells[iCol+1].style.background=c_rgszClr[4]; } } } else cells[iCol].style.background=c_rgszClr[fActive?2:4]; } } } with (aTab[iTab].style) { cursor=(fActive?"default":"hand"); color=c_rgszClr[3]; } } }}function fnMouseOverScroll(iCtl){ frames['frScroll'].document.all.tdScroll[iCtl].style.color=c_rgszClr[7];}function fnMouseOutScroll(iCtl){ frames['frScroll'].document.all.tdScroll[iCtl].style.color=c_rgszClr[6];}function fnMouseOverTab(iTab){ if (iTab!=g_iShCur) { var iCol=fnTabToCol(iTab); with (frames['frTabs'].document.all) { tdTab[iTab].style.background=c_rgszClr[5]; } }}function fnMouseOutTab(iTab){ if (iTab>=0) { var elFrom=frames['frTabs'].event.srcElement; var elTo=frames['frTabs'].event.toElement; if ((!elTo) || (elFrom.tagName==elTo.tagName) || (elTo.tagName=="A" && elTo.parentElement!=elFrom) || (elFrom.tagName=="A" && elFrom.parentElement!=elTo)) { if (iTab!=g_iShCur) { with (frames['frTabs'].document.all) { tdTab[iTab].style.background=c_rgszClr[1]; } } } }}function fnSetActiveSheet(iSh){ if (iSh!=g_iShCur) { fnSetTabProps(g_iShCur,false); fnSetTabProps(iSh,true); g_iShCur=iSh; }} window.g_iIEVer=fnGetIEVer(); if (window.g_iIEVer>=4) fnBuildFrameset();//--></script><![endif]><!--[if gte mso 9]><xml> <x:ExcelWorkbook> <x:ExcelWorksheets> <x:ExcelWorksheet> <x:Name>Daily13</x:Name> <x:WorksheetSource HRef="1000.files/sheet001.htm"/> </x:ExcelWorksheet> <x:ExcelWorksheet> <x:Name>Intra13</x:Name> <x:WorksheetSource HRef="1000.files/sheet002.htm"/> </x:ExcelWorksheet> </x:ExcelWorksheets> <x:Stylesheet HRef="1000.files/stylesheet.css"/> <x:WindowHeight>6225</x:WindowHeight> <x:WindowWidth>13995</x:WindowWidth> <x:WindowTopX>480</x:WindowTopX> <x:WindowTopY>120</x:WindowTopY> <x:ProtectStructure>False</x:ProtectStructure> <x:ProtectWindows>False</x:ProtectWindows> </x:ExcelWorkbook> <x:ExcelName>
1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:16:17:18:19:20:21:22:23:24:25:26:27:28:29:30:31:32:33:34:35:36:37:38:39:40:41:42:43:44:45:46:47:48:49:50:51:52:53:54:55:56:57:58:59:60:61:62:63:64:65:66:67:68:69:70:71:72:73:74:75:76:77:78:79:80:81:82:83:84:85:86:87:88:89:90:91:92:93:94:95:96:97:98:99:100:101:102:103:104:105:106:107:108:109:110:111:112:113:114:115:116:117:118:119:120:121:122:123:124:125:126:127:128:129:130:131:132:133:134:135:136:137:138:139:140:141:142:143:144:145:146:147:148:149:150:151:152:153:154:155:156:157:158:159:160:161:162:163:164:165:166:167:168:169:170:171:172:173:174:175:176:177:178:179:180:181:182:183:184:185:186:187:188:189:190:191:192:193:194:195:196:197:198:199:200:201:202:203:204:205:206:207:208:209:210:211:212:213:214:215:216:217:218:219:220:221:222:223:224:225:226:227:228:229:230:231:232:233:234:235:236:237:238:239:240:241:242:243:244:245:246:247:248:249:250:251:252:253:254:255:256:257:258:259:260:261:262:263:264:265:266:267:268:269:270:271:272:273:274:275:276:277:278:279:280:281:282:283:284:285:286:287:288:289:290:291:292:293:294:295:296:297:298:299:300:301:302:303:304:305:306:307:308:309:310:311:312:313:314:315:316:317:318:319:320:321:322:323:324:325:326:327:328:329:330:331:332:333:334:335:336:
1.
document.getElementById("frame1").contentWindow.document.body.style.marginTop='0';
document.getElementById("frame1").contentWindow.document.body.style.marginLeft='0';
2.
Try
overflow:auto