Forum Discussion
fzaborowski_311
Nimbostratus
Apr 05, 2010iRule Javascript call?
Hi,
Quick question (I haven't seen this done/documented here):
I wish to call a .js file for users accessing certain pages. The script simply tags their page for us to m...
hoolio
Cirrostratus
Apr 06, 2010The URI isn't saved for response events. So you could check the URI in HTTP_REQUEST and then set a variable to 1 to track whether to inject the javascript in the response:
when HTTP_REQUEST {
Check if some URI property is true
if {[string tolower [HTTP::path]] contains "/foopage/"}{
Track that we'll inject the js in the response
set inject_js 1
} else {
Track that we won't inject the js in the response
set inject_js 0
}
}
when HTTP_RESPONSE {
Check whether we're injecting the js in the response payload
if {$inject_js==1}{
Do it...
}
}
Also note that it would probably be more efficient to use a stream profile to insert the javascript. See this post for a related example:
http://devcentral.f5.com/Default.aspx?tabid=53&aff=5&aft=1144860&afv=topic&afpgj=1
Aaron
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects