Developer forum

Forum » Development » unknown Javascript in templates

unknown Javascript in templates


Reply

Hi

Were setting up a DW site in XML templates to be able to render the pages to flash.

this works out pretty well but sometimes (I dont know exactly when as it seems a bit random) some javascript is generated in the templates which of course breaks the XML and destroys the rendering in flash.

 

Where and why is it rendered, and how do we disable it?

 

this is the script tag

<script type="text/javascript">
	strLink = "Admin/Public/Stat2.aspx?SessionID=o0w5o045i3e1s055jgyn1vqv"
	strLink += "&width=" + window.screen.width;
	strLink += "&height=" + window.screen.height;
	strLink += "&col=" + window.screen.colorDepth;
	if((navigator.userAgent.toLowerCase().indexOf('msie 5') > 0 || navigator.userAgent.toLowerCase().indexOf('msie 5.5')> 0 || navigator.userAgent.toLowerCase().indexOf('msie 6')> 0 || navigator.userAgent.toLowerCase().indexOf('msie 7')> 0) && navigator.userAgent.toLowerCase().indexOf('opera')<1){
		document.writeln('<HTML xmlns:IE><IE:CLIENTCAPS ID=oClientCaps style="behavior:url(#default#clientCaps)"/></HTML>');
		strLink += "&con=" + oClientCaps.connectionType;
		strLink += "&lan=" + window.navigator.userLanguage;
	}
	if((navigator.userAgent.toLowerCase().indexOf('firefox') > 0 || navigator.userAgent.toLowerCase().indexOf('netscape')> 0 || navigator.userAgent.toLowerCase().indexOf('opera')> 0)){
		strLink += "&lan=" + window.navigator.language;
	}
	document.writeln('<scr'+'ipt language="JavaScript1.2" src="' + strLink + '" type="text/javascript"></scr'+'ipt>');
</script>

- Sune

Replies

 
Reply

Thats atleast the statics module, hope that will get you pointed to the right direction.

 
Nicolai Høeg Pedersen
Reply

As Jais pointed out it is statistics module giving this JS. It comes when a new session starts.

 

Its added to the end of pageview.output and part of the template tag "PageContent" in master template.

 

The only way to disable it, is by disabling the entire statistics module from control panel.

 

Alternatively you can remove the script using a regex in Default.aspx.vb/cs or by using the Notifications.Standard.Page.AfterOutput notification.

 
Reply
np wrote:

As Jais pointed out it is statistics module giving this JS. It comes when a new session starts.

 

Its added to the end of pageview.output and part of the template tag "PageContent" in master template.

 

The only way to disable it, is by disabling the entire statistics module from control panel.

 

Alternatively you can remove the script using a regex in Default.aspx.vb/cs or by using the Notifications.Standard.Page.AfterOutput notification.

Thanks Ill try that

 
Reply
np wrote:

As Jais pointed out it is statistics module giving this JS. It comes when a new session starts.

 

Its added to the end of pageview.output and part of the template tag "PageContent" in master template.

 

The only way to disable it, is by disabling the entire statistics module from control panel.

 

Alternatively you can remove the script using a regex in Default.aspx.vb/cs or by using the Notifications.Standard.Page.AfterOutput notification.

The site we're working on's Default.aspx inherits from Dynamicweb.Admin.Load.

Since I cant edit in this codebehind what do I do to add code to the codebehind of the default.aspx?

 

All my Custommodules are split up and uses the "AddinName" property.

 

- Sune

 
Nicolai Høeg Pedersen
Reply

Use the Notifications.Standard.Page.AfterOutput notification:

 

<Subscribe(Dynamicweb.Notifications.Standard.Page.AfterOutput)> _

Public Class PageAfteroutputSubscriber

Inherits Extensibility.NotificationSubscriber

Public Overrides Sub OnNotify(ByVal notification As String, ByVal args As Object())

Dim t As Templatev2.Template = DirectCast(args(0), Templatev2.Template)

Dim output As String = t.Html

'output = System.Text.RegularExpressions.Regex.Replace()

t.Html = output

End Sub

End Class

 

 
Reply
np wrote:

Use the Notifications.Standard.Page.AfterOutput notification:

 

<Subscribe(Dynamicweb.Notifications.Standard.Page.AfterOutput)> _

Public Class PageAfteroutputSubscriber

Inherits Extensibility.NotificationSubscriber

Public Overrides Sub OnNotify(ByVal notification As String, ByVal args As Object())

Dim t As Templatev2.Template = DirectCast(args(0), Templatev2.Template)

Dim output As String = t.Html

'output = System.Text.RegularExpressions.Regex.Replace()

t.Html = output

End Sub

End Class

 

Smooth. Works lika charm

 

- Sune

 

You must be logged in to post in the forum