我在 IE 中遇到自动搜索 javascript 的问题。它在 Firefox 中正常工作。要了解我在说什么,请访问:
然后开始在搜索栏中输入单词购物车。您会在 Firefox 中看到它在下方排列,但在 IE 中却没有。任何帮助将不胜感激!
这是代码:
<script type="text/javascript">
function findPos(obj) {
var curleft = curtop = 0;
if (obj.offsetParent) {
do {
curleft += obj.offsetLeft;
curtop += obj.offsetTop;
} while (obj = obj.offsetParent);
}
return curleft.toString() + ' ' + curtop.toString();
}
(function() {
var nxt_host = (("https:" == document.location.protocol) ? "https://" : "http://");
nxt_host += "vector.nextopiasoftware.com/";
document.write(unescape("%3C") + "script src='" + nxt_host + "nxt-ac-js-1.3-min.js' type='text/javascript'" + unescape("%3E%3C/script%3E"));
document.write(unescape("%3C") + "link rel='stylesheet' type='text/css' href='" + nxt_host + "ac-1.3.css'" + unescape("%3E"));
})();
</script>
<script type="text/javascript">
(function() {
var jnxtac = jQuery.noConflict(true);
jnxtac("#myInput").css('z-index', '20000');
jnxtac("#myInput").autocomplete({
cid: '80c356394c27c27aacf41c465e455f7d'
});
})();
if (navigator.appVersion.indexOf("MSIE") != -1) {
var offsets = findPos(document.getElementById('search')).split(' ');
var acStyleEl = document.createElement('style');
var acStyleCss = '.ui-autocomplete {position:absolute !important;left: ' + (parseInt(offsets[0]) + 200) + 'px !important; top: ' + (parseInt(offsets[1]) + 24) + 'px !important;}';
var bodyEl = document.getElementsByTagName('body')[0];
acStyleEl.setAttribute("type", "text/css");
acStyleEl.setAttribute("id", "acCssElement");
bodyEl.appendChild(acStyleEl);
acStyleEl.styleSheet.cssText = acStyleCss;
}
</script>
任何帮助将不胜感激!