2010-01-05 26 views
0

我在我的頁面上使用了一個文字,它有一個html表單。當單擊特定鏈接時,會顯示此文字,頁面上會顯示覆蓋div,並在覆蓋div上顯示該表單。所有的瀏覽器都能正常工作,並且和預期的完全一樣,但IE並沒有在覆蓋div上顯示任何內容,即覆蓋div顯示但是爲空。我曾試着向文字控件逐個添加標籤,以查看究竟哪個標籤導致了問題,並發現所有內容(HTML輸入控件等)都顯示在覆蓋div上,直到<form>標籤被添加到文字中文本。
如果literal.Text屬性沒有<form>標記,那麼IE中的內容也會顯示正常。但問題是我需要在文字內部有<form>,因爲我必須將數據發回到外部鏈接。當所有其他瀏覽器工作正常,在IE中可能是什麼問題?IE沒有顯示<form>標籤的文字文字

以下是文字內容時,它的設定:

formSalesForce.Text = "<div style='clear:both'></div><h2 class='sIFR-replaced1' style='text-align:left'><embed height='20' id='h2heading' width='282' src='frutiger_light.swf' quality='best' flashvars='txt=Document Description&amp;textalign=left&amp;offsetTop=0&amp;textcolor=#878787&amp;hovercolor=#76b404&amp;linkcolor=#87be22&amp;w=282&amp;h=20' wmode='transparent' bgcolor='transparent' sifr='true' type='application/x-shockwave-flash' class='sIFR-flash1' style='width: 282px; height: 20px;'/><span class='sIFR-alternate'>Document Description</span></h2>" + d.DocDescription + "<BR><p>Please fill out the following information so that we can proceed with providing you the link to the document</p><form id='myDocForm' name='myDocForm' action='" + d.DataSubmissionPath + "' method='POST' ><table class='clearBoth' width='45%'><tr><td><input type=hidden name='oid' value='" + d.OID + "'></td><td><input type=hidden name='retURL' value='" + "" + "'></td></tr><tr><td class='formlabel' >First Name*</td><td class='formfield'><input type='text' id='first_name' size='20' maxlength='40' name='first_name'></td></tr><tr><td class='formlabel'>Last Name*</td><td class='formfield'><input type='text' id='last_name' size='20' maxlength='40' name='last_name'></td></tr><tr><td class='formlabel'>Email*</td><td class='formfield'><input type='text' id='email' size='20' maxlength='40' name='email'></td></tr><tr><td class='formlabel'>Work Title</td><td class='formfield'><input type='text' id='work_title' size='20' maxlength='40' name='work_title'></td></tr><tr><td class='formlabel'>Company</td><td class='formfield'><input type='text' id='company' size='20' maxlength='40' name='company'></td></tr><tr><td class='formbuttons'><input type='Button' name='btnsubmit' value='Submit' onclick='showDocPanel();'></td></tr></table></form>" 
+0

請提供字面控制的內容嗎? – Himadri 2010-01-05 06:45:43

+0

當您查看源代碼時,您是否看到'

'元素?不是說你有兩種形式(一種來自asp.net),所以他們不會像你期望的那樣行事。你有沒有嘗試過老式的iframe? – Kobi 2010-01-05 06:47:46

+0

對不起stackoverflow.com在我的最後沒有打開,所以我不能早先回復你的帖子。 @Kobi:我看不到表單,當我查看頁面的源代碼時,我知道我有兩種形式,一種是aspnet,一種是基於html的正常...但事情是,我已經得到它的工作在其他瀏覽器,但不是IE – ria 2010-01-05 07:37:45

回答

1

我不得不做以下解決方法:

我用Request.Browser.Browser檢查瀏覽器是否爲IE ...然後我修改了文字文字如下:

Dim s As New StringBuilder 
    s.Append("<iframe name='myIframe' style='visibility:hidden;height:0;width:0;'></iframe><div style='clear:both'></div><h2 class='sIFR-replaced1' style='text-align:left'><embed height='20' id='h2heading' width='282' src='swf/frutiger_light.swf' quality='best' flashvars='txt=Document Description&amp;textalign=left&amp;offsetTop=0&amp;textcolor=#878787&amp;hovercolor=#76b404&amp;linkcolor=#87be22&amp;w=282&amp;h=20' wmode='transparent' bgcolor='transparent' sifr='true' type='application/x-shockwave-flash' class='sIFR-flash1' style='width: 282px; height: 20px;'/><span class='sIFR-alternate'>Document Description</span></h2><p align='left'><i>" + d.DocDescription + "</i><BR><BR></p>") 
    s.Append("<p>Please fill out the following information so that we can proceed with providing you the link to the document</p>") 
    If (Not Request.Browser.Browser.Equals("IE")) Then 
     s.Append("<form id='myDocForm' name='myDocForm' target='myIframe' action='" + d.DataSubmissionPath + "' method='POST' >") 
    End If 

    s.Append("<table class='clearBoth' width='45%'><tr><td>") 
    s.Append("<input type=hidden name='oid' id='oid' value='" + d.OID + "'></td><td>") 
    s.Append("<input type=hidden name='retURL' id='retURL' value='" + "" + "'></td></tr>") 

    ' debug(info) 
    s.Append("<input type='hidden' name='debug' value=1>") 
    s.Append("<input type='hidden' name='debugEmail'") 
    s.Append("value=''>") 

    s.Append("<tr><td class='formlabel'>First Name*</td>") 
    s.Append("<td class='formfield'><input type='text' id='first_name' size='20' maxlength='40' name='first_name'>") 
    s.Append("</td></tr>") 
    s.Append("<tr><td class='formlabel'>Last Name*</td>") 
    s.Append("<td class='formfield'><input type='text' id='last_name' size='20' maxlength='40' name='last_name'>") 
    s.Append("</td></tr>") 
    s.Append("<tr><td class='formlabel'>Email*</td>") 
    s.Append("<td class='formfield'><input type='text' id='email' size='20' maxlength='40' name='email'>") 
    s.Append("</td></tr>") 
    s.Append("<tr><td class='formlabel'>Work Title</td>") 
    s.Append("<td class='formfield'><input type='text' id='work_title' size='20' maxlength='40' name='work_title'>") 
    s.Append("</td></tr>") 
    s.Append("<tr><td class='formlabel'>Company</td>") 
    s.Append("<td class='formfield'><input type='text' id='company' size='20' maxlength='40' name='company'>") 
    s.Append("</td></tr>") 
    s.Append("<tr><td>&nbsp;</td>&nbsp;<td></td></tr>")  'empty row for spacer cells 
    s.Append("<tr><td>&nbsp;</td><td class='formbuttons' align='right'><input type='Button' id='btnsubmit' name='btnsubmit' value='Submit' onclick='showDocPanel();'>") 
    s.Append("</td></tr>") 
    s.Append("</table>") 
    If (Not Request.Browser.Browser.Equals("IE")) Then 
     s.Append("</form>") 
    End If 
formSalesForce.Text=s.ToString() 

因此,IE瀏覽器顯示該表時,因爲在使用IE時沒有標籤附加到文字上。

現在;當使用IE瀏覽器,我有一個擔心張貼到外部網站的形式,因爲沒有形式,它無法提交...因此,我不得不使用javascript創建一個副本表單:

使用此JavaScript段從該網站採取:http://en.allexperts.com/q/Javascript-1520/create-form-submit-fly.htm

function getNewSubmitForm(){ 
var submitForm = document.createElement("FORM"); 
document.body.appendChild(submitForm); 
submitForm.method = "POST"; 
return submitForm; 
} 

//helper function to add elements to the form 
function createNewFormElement(inputForm, elementName, elementValue){ 
var newElement = document.createElement("<input name='"+elementName+"' id='" + elementName + "' type='hidden'>"); 
inputForm.appendChild(newElement); 
newElement.value = elementValue; 
return newElement; 
} 

//function that creates the form, adds some elements 
//and then submits it 
function createFormAndSubmit(){ 
var submitForm = getNewSubmitForm(); 
//alert("form created"); 
createNewFormElement(submitForm, "oid", document.getElementById("oid").value); 
createNewFormElement(submitForm, "debug", "1"); 
createNewFormElement(submitForm, "debugEmail", ""); 
createNewFormElement(submitForm, "first_name", document.getElementById("first_name").value); 
createNewFormElement(submitForm, "last_name", document.getElementById("last_name").value); 
createNewFormElement(submitForm, "email", document.getElementById("email").value); 
createNewFormElement(submitForm, "work_title", document.getElementById("work_title").value); 
createNewFormElement(submitForm, "company", document.getElementById("company").value); 
createNewFormElement(submitForm, "retURL", window.location.href); 
//alert(window.location.href + "::elements added"); 
submitForm.action= "my external website url"; 
submitForm.target='myIframe'; 
//alert("submitting"); 
submitForm.submit(); 
} 

現在有一個回發發生的歷史時提交給外部URL的形式,工作,圍繞我所做的:

  • 創建一個隱藏的iframe,並追加到文字文本(參見上面的代碼爲文本文本)
  • 設置形式的目標是該幀的名稱(參見上面的代碼爲文字文本)
  • 設置重複的javascript形式的目標是該幀(見的JavaScript代碼以上)
  • 的名稱
0

設置窗體保證金Zero也應該工作:

.formStyle { 保證金:0像素; }