简体   繁体   English

javascript函数中的sIFR和document.write

[英]sIFR and document.write within a javascript function

I am trying to style some html through a javascript loop which outputs the html through the document.write(); 我正在尝试通过一个JavaScript循环来设置html样式,该循环通过document.write()输出html。 function. 功能。 My CSS styles seem to come through correctly, however my sifr classes are not calling my flash file for some reason. 我的CSS样式似乎正确通过了,但是由于某些原因,我的sifr类没有调用Flash文件。 I was thinking it might have something to do with the javascript document.write function I am using. 我以为它可能与我使用的javascript document.write函数有关。

Id like to know if it is possible to use SIFR in this way. 我想知道是否可以这种方式使用SIFR。 If not, does anyone have any alternatives to what Im doing? 如果没有,那么有人能代替Im做些什么吗?

Here is my code: (basically, I am loading data from an XML file and outputting it as HTML with document.write - I have bolded the piece of code that I am reffering to. I am a designer who trys to write javascript, so keep that in mind before tearing apart my function. =) 这是我的代码:(基本上,我是从XML文件中加载数据,并使用document.write将其输出为HTML-我加粗了我所引用的那段代码。我是一位尝试编写JavaScript的设计师,因此在拆解我的功能之前,请记住这一点。=)

document.write("<h1 class="h1_sifr_green">Tours in the <br />");
document.write(search_term.toUpperCase());
document.write(" area:</h1><br /><br />");

Again, my h1 tag comes through fine, as well as all my other css classes EXCEPT my sifr class. 再次,我的h1标签以及我的sifr类之外的所有其他css类都通过了。 Thanks in advance, any help here is appreciated. 在此先感谢您的帮助。

Here is my code in it's entirety: 这是我的全部代码:

<html>
<head>
<link href="../css/colors.css" rel="stylesheet" type="text/css" />
<link href="../css/layout.css" rel="stylesheet" type="text/css" />
<link href="../css/textstyles.css" rel="stylesheet" type="text/css" />
<link href="../css/sifr.css" rel="stylesheet" type="text/css" />

<script type="text/javascript" src="js/sifr.js"></script>
<script type="text/javascript" src="js/sifr-config.js"></script>

<script type="text/javascript">
function parseXML()
{

var search_term=window.location.search.substring(1);  //sets the search_term variable to the URL string query
var tour_name;
var tour_link;
var tour_logo;

try //Internet Explorer
  {
  xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
  }
catch(e)
  {
  try //Firefox, Mozilla, Opera, etc.
    {
    xmlDoc=document.implementation.createDocument("","",null);
    }
  catch(e)
    {
    alert(e.message);
    return;
    }
  }
xmlDoc.async=false;
xmlDoc.load(search_term + ".xml");

x=xmlDoc.documentElement.childNodes;

document.write("<h1 class=\"h1_sifr_green\">Tours in the <br />");
document.write(search_term.toUpperCase());
document.write(" area:</h1><br /><br />");

for (i=0;i<x.length;i++)
  {
  tour_name=xmlDoc.getElementsByTagName("name")[i].firstChild.nodeValue;
  tour_link=xmlDoc.getElementsByTagName("tourlink")[i].firstChild.nodeValue;
  document.write("<a href=\"" + tour_link + "\" class=\"b3 textlink\">" + tour_name + "</a>");
  document.write("<br />");
  }
}

</script>
</head>

<body>
<div id="wrap" style="background-image:url(../images/index_06.jpg); width:550px">
<div style="padding:30px">
<script type="text/javascript" language="JavaScript">
    parseXML();
</script>
</div>

</div>
</body>
</html>

是的,当您的.js文件未正确链接时,请务必爱...链接已断开,链接已固定,问题已解决。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM