简体   繁体   English

如何在URLRequest Flex 4 / Air中替换HTML标签

[英]How to replace HTML tag in URLRequest Flex 4 / Air

I am embedding a website into my application, and Adobe Air does not recognize the breakline HTML tag in the source code (Firefox and Chrome auto-correct the error). 我将网站嵌入到我的应用程序中,并且Adobe Air无法在源代码中识别出换行符HTML标签(Firefox和Chrome会自动更正错误)。 I have attached the source code below. 我已附上以下源代码。 Is there a way to replace the breakline with the correct syntax (no forward slash). 有没有一种方法可以使用正确的语法(没有正斜杠)替换换行符。 I do not control the website, I am merely loading it into my application, so I can't just change it at the source. 我不控制网站,我只是将其加载到我的应用程序中,所以我不能只在源代码上进行更改。 I am using an mx:html object and htmlLoader to load the url. 我正在使用mx:html对象和htmlLoader加载网址。

Website Source: 网站来源:

<ul>
    <li><a href="Rpt_Selection_2.asp?Report=StatusReport/StatusReport.asp">Status Report</a></li>
    <li><a href="Rpt_Selection_2.asp?Report=StatusReport/AlarmsAlerts.asp">Alarm History</a></li>
</ul>

<br/>

<table class="Header" cellspacing="0" cellpadding="0" border="0">
    <tr>
      <td class="HeaderLeft"><img src="Images/Spacer.gif" border="0"></td> 
      <th>List of&nbsp;Alarms for Multiple Groups&nbsp;</th>
      <td class="HeaderRight"><img src="Images/Spacer.gif" border="0"></td>
    </tr>
</table>

mxml Component: mxml组件:

<mx:HTML  id="htmlControl" width="100%" height="100%"/>

Script to load URL: 加载URL的脚本:

htmlControl.htmlLoader.load(new URLRequest("http://mysite.com/somepage.asp"));

Thanks you. 谢谢。

The way I've handled this in the past was to use a URLLoader to first retrieve the content, then modify it, then set the content into an HTML component by calling myHtmlComponent.htmlLoader.loadString(myModifiedContent) 我过去处理此问题的方式是使用URLLoader首先检索内容,然后对其进行修改,然后通过调用myHtmlComponent.htmlLoader.loadString(myModifiedContent)将内容设置为HTML组件。

Hope that helps. 希望能有所帮助。

EDIT: After reading the comment below, you may be having trouble with loading referenced scripts if they are referred to using a relative URL rather than the full URL. 编辑:阅读下面的评论后,如果使用相对URL而非完整URL引用引用的脚本,则可能无法加载引用的脚本。 I've fixed this in the past by prepending a base tag so the relative URLs can resolve properly. 过去,我已经通过在基础标签前面添加了固定代码,以便可以正确解析相对URL。 After retrieving the content, and before calling myHtmlComponent.htmlLoader.loadString, prepend like so: 在检索内容之后,并在调用myHtmlComponent.htmlLoader.loadString之前,请像这样预先添加:

myModifiedContent = "<base href='http://mydomain.com/'/>" + myModifiedContent;

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

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