有几个ASP.net页面调用.aspx“联系我们”文件,其中包含下拉菜单以选择不同的办公室及其数据。这在Chrome和Firefox中运行良好,在IE中已经破解。
下拉框的数据位于Default.Master文件中。我不是一个ASP.net程序员,但知道足以做出轻微的,偶尔的变化。
如果您在IE浏览器中访问新网站,则下拉工作正常。如果您选择除Puyallup之外的下拉菜单然后刷新,则下拉列表会中断。如果清除临时文件并刷新,它将再次起作用。
'contactbar.aspx'的代码:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="contactbar.ascx.cs" Inherits="HiLine.Web.UserControls.contactbar" %>
<div id="sidebar-main">
<div class="sidebar" id="contact">
<h4>
Contact Us</h4>
<select name="location" id="location">
<option value="1">Puyallup, WA</option>
<option value="8">Burlington, WA</option>
<option value="10">Central Oregon</option>
<option value="3">Centralia, WA</option>
<option value="4">Grays Harbor, WA</option>
<option value="13">Moses Lake, WA</option>
<option value="2">Oly. Peninsula, WA</option>
<option value="16">Roseburg, OR</option>
<option value="9">Salem, OR</option>
<option value="15">Spokane, WA</option>
<option value="7">Tri-Cities, WA</option>
<option value="14">Wenatchee, WA</option>
<option value="5">Woodland, WA</option>
<option value="6">Yakima, WA</option>
</select>
<div id="default" style="display: block; visibility: visible;">
<p>
Select one of our offices closest to the location where you intend to build a home.</p>
</div>
<div id="contactDiv" style="display: none; visibility: hidden;">
<p id="address">
1888 Belmont Loop<br />
Woodland, WA 98674</p>
<p id="phonefax">
<b>Tel:</b> 360-225-1768<br />
<b>Fax:</b> 360-225-7813</p>
<p id="officehours">
<b>Office Hours:</b><br />
9:00-5:30 Monday-Saturday</p>
<div id="featuresVary" style="margin: 10px; margin-left: 15px; font-size: 11px; clear: both; border: 1px solid white; padding: 4px;
background-color: #f37121;">
Features, Options and Promotional Offers May Vary By Location. Contact Your Local Sales Office For Additional Information or to make an after hours appointment.
</div>
<a href="contactform2.aspx">
<img src="images/email_btn.gif" style="float: right; margin-right: 17px;" id="sendmail_btn" alt="Send Email" /></a>
</div>
<p> </p>
</div>
<div style="background:none;padding-left:18px;padding-top:15px;margin-top:30px;">
<script type="text/javascript" src="http://static.ak.connect.facebook.com/connect.php/en_US"></script><script type="text/javascript">FB.init("022348d39113d1fd3da56159b62598f7");</script><fb:fan profile_id="214974200273" stream="0" connections="6" logobar="1" width="180"></fb:fan>
</div>
<img id="energy_star" src="images/energy_star.gif" />
</div>
在ASP.net页面上,代码中列出的所有内容都是:
<hiline:contact id="contact" runat="server" />
在Default.Master文件中,这是代码:
<script type="text/javascript">
var contactInfo = new Array();
// [display address, gmaps address, phone/fax, office hours, model home]
contactInfo["1"] = ["11210 Woodland Ave E.<br />Puyallup, WA 98373", "11210 Woodland Ave E., Puyallup, WA 98373", "<b>Tel:</b> <a class='mobile' href='tel:+12538401722'>253-840-1722</a><br /><b>Fax:</b> 253-840-1836<br /><br /><a href='http://www.hilinehomespuyallup.com' target='_blank'><img src='images/webani.gif' width='175' height='30' /></a>", "<b>Office Hours:</b><br />9:00-5:00<br />Monday-Saturday", "1716"];
contactInfo["2"] = ["Call for an Appointment", "92 Kala Square Place Port Townsend, WA 98368", "<b>Tel:</b> (866) 789-3507", "<b>Office Hours:</b><br />9:00-5:30<br />Monday-Saturday", "1716"];
contactInfo["3"] = ["Call for an Appointment", "1213 Long Road, Centralia, WA 98531", "<b>Tel:</b> (866) 745-4553", "<b>Office Hours:</b><br />9:00-5:30<br />Monday-Saturday", "1716"];
contactInfo["4"] = ["306 4th St.<br />Satsop, WA 98583", "306 4th St., Satsop, WA 98583", "<b>Tel:</b><a class='mobile' href='tel:+13604824224'>360-482-4224</a><br /><br /><a href='http://www.hilinehomesgraysharbor.com' target='_blank'><img src='images/webani.gif' width='175' height='30' /></a>", "<b>Office Hours:</b><br />9:00-5:00<br />Monday-Saturday", "1716"];
contactInfo["5"] = ["1888 Belmont Loop Road<br />Woodland, WA 98674", "1888 Belmont Loop, Woodland, WA 98674", "<b>Tel:</b> <a class='mobile' href='tel:+13602551768'>360-225-1768</a><br /><b>Fax:</b> 360-225-7813<br /><br /><a href='http://www.hilinehomeswoodland.com' target='_blank'><img src='images/webani.gif' width='175' height='30' /></a>", "<b>Office Hours:</b><br />9:00-5:00<br />Monday-Saturday", "1716"];
contactInfo["6"] = ["2410 Terrace Hts. Dr.<br />Yakima, WA 98901", "2410 Terrace Heights. Dr., Yakima, WA 98901", "<b>Tel:</b><a class='mobile' href='tel:+15095751722'> 509-575-1722<a/><br /><b>Fax:</b> 509-575-1851", "<b>Office Hours:</b><br />9:00-5:00<br />Monday-Saturday", "1716"];
contactInfo["7"] = ["5520 West Hood Ave.<br />Kennewick, WA 99336", "5520 West Hood Ave. Kennewick, WA 99336", "<b>Tel:</b> <a class='mobile' href='tel:+15097351722'>509-735-1722</a><br /><b>Fax:</b> 509-735-3415", "<b>Office Hours:</b><br />9:00-5:00<br />Monday-Saturday", "1716"];
contactInfo["16"] = ["Call for an Appointment", "2101 SE Stellers Eagle Street, Roseburg, OR 97470", "<b>Tel:</b> <a class='mobile' href='tel:+15419571721'>541-957-1721</a><br /><br /><div id='webani'><a href='http://www.hilinehomesroseburg.com' target='_blank'><img src='images/webani.gif' width='175' height='30' /></a>", "<b>Office Hours:</b><br />9:00-5:00<br />Monday-Saturday", "1716"];
contactInfo["9"] = ["3935 Hagers Grove Rd. SE.<br />Salem, OR 97317", "3935 Hagers Grove Rd. SE., Salem, OR 97317", "<b>Tel:</b> <a class='mobile' href='tel:+15033991721'>503-399-1721</a><br />CCB# 181652<br /><br /><div id='webani'><a href='http://www.hilinehomessalem.com' target='_blank'><img src='images/webani.gif' width='175' height='30' /></a>", "<b>Office Hours:</b><br />9:00-5:00<br />Monday-Saturday", "1716"];
contactInfo["10"] = ["<b>Model Home:</b><br />1454 NW Maple Rim Court<br />Redmond, OR 97756", "<b>Model Home:</b><br />1454 NW Maple Rim Court<br />Redmond, OR 97756", "<b>Tel:</b><a class='mobile' href='tel:+15416471600'>541-647-1600</a><br /><br /><a href='http://www.hilinehomescentraloregon.com' target='_blank'><img src='images/webani.gif' width='175' height='30' /></a>", "<b>Model Hours:</b><br />9:00-5:00<br />Monday-Saturday"];
contactInfo["14"] = ["1848 N Wenatchee Ave<br />Wenatchee, WA. 98801", "1818 N Wenatchee Ave<br />Wenatchee, WA. 98801", "<b>Tel:</b> <a class='mobile' href='tel:+15096631722'>509-663-1722</a>", "<b>Office Hours:</b><br />9:30-5:30<br />Tuesday-Saturday", "1716"];
contactInfo["15"] = ["506 N Vercler St.<br />Spokane Valley, WA 99216", "15320 E Marietta Ave. Suite #2<br />Spokane Valley, WA 99216", "<b>Tel:</b> <a class='mobile' href='tel:+15093211000'>509-321-1000</a>", "<b>Office Hours:</b><br />9:00-5:30<br />Monday-Saturday", "1716"];
contactInfo["13"] = ["1611 South Beaumont Drive<br />Moses Lake, WA 98837", "1611 South Beaumont Drive<br />Moses Lake, WA 98837", "<b>Tel:</b> <a class='mobile' href='tel:+15097642345'>509-764-2345</a>", "<b>Office Hours:</b><br />10:00-5:00<br />Friday and Saturday", "1716"];
contactInfo["8"] = ["489 Andis Road<br />Burlington, WA 98233", "489 Andis Road Burlington, WA 98233", "<b>Tel:</b> 360-707-2112", "<b>Office Hours:</b><br />10:00-5:00<br />Friday and Saturday", "1716"];
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}
function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}
function addListener(element, event, listener, bubble) {
if(element != null)
{
if(element.addEventListener) {
if(typeof(bubble) == "undefined") bubble = false;
element.addEventListener(event, listener, bubble);
} else if(this.attachEvent) {
element.attachEvent("on" + event, listener);
}
}
}
//swaps out contact info
function swapContactInfo () {
officeSelect = document.getElementById("location");
if(officeSelect != null)
{
whichOffice = officeSelect.options[officeSelect.selectedIndex].value;
var defaultDiv = document.getElementById("default");
var contactDiv = document.getElementById("contactDiv");
var directionsDiv = document.getElementById("directions");
setCookie("Office", whichOffice, 30);
if(whichOffice != "none"){
myAddress = document.getElementById("address");
myAddress.innerHTML = contactInfo[whichOffice][0];
myPhone = document.getElementById("phonefax");
myPhone.innerHTML = contactInfo[whichOffice][2];
myHours = document.getElementById("officehours");
myHours.innerHTML = contactInfo[whichOffice][3];
if(thisPage == "buildarea") {
officeText = document.getElementById("officeName");
myOffice = officeSelect.options[officeSelect.selectedIndex].text;
if(myOffice=="graysharbor") {
myOffice = "grays harbor";
}
officeText.innerHTML = myOffice + " ";
directionsDiv.style.visibility = "visible";
directionsDiv.style.display = "block";
}
defaultDiv.style.visibility = "hidden";
defaultDiv.style.display = "none";
contactDiv.style.visibility = "visible";
contactDiv.style.display = "block";
} else {
if(thisPage == "buildarea") {
directionsDiv.style.visibility = "hidden";
directionsDiv.style.display = "none";
}
defaultDiv.style.visibility = "visible";
defaultDiv.style.display = "block";
contactDiv.style.visibility = "hidden";
contactDiv.style.display = "none";
}
}
}
还有其他代码,但我认为这是相关的东西。
答案 0 :(得分:1)
看看是否评论
setCookie("Office", whichOffice, 30);
解决了您的问题。它看起来不像那个cookie的结果在那个页面上使用,但是这可能会在setCookie()函数中出现问题,因为不同的浏览器为cookie实现API的方式有点不同。
您需要确保此Cookie实际上不在其他地方使用...