I have a js function that will be executed automatically page initialized. This js will be called and executed perfectly when first open the page, but when I postback (click the link on asp.net page) page, it will not be called and the function broken.
This is my js function in Default.aspx:
<script type="text/javascript">
function HightLightKeywords() {
var container = document.getElementById("result");
var keywords = new Array();
<%
// This is C# code runs in server side.
for (int i = 0; i < keywords.Count; i++)
{
Response.Write(string.Format("keywords['{0}'] = '{1}';", i, keywords[i]));
}
%>
for (var i = 0; i < keywords.length; i++)
{
var a = new RegExp(keywords[i], "igm");
container.innerHTML = container.innerHTML.replace(a, "<span style='background:#FF0;'>" + keywords[i] + "</span>");
}
}
HightLightKeywords();
</script>
it only executed once first enter the Default.aspx, it doesn't trigger twice after I click the button on the page (postback).
Is this related to client cache? Is there a way(by setting some properties?) to prevent client cache when postback?
Thanks