Only if form
action is /?cms_mode=edit
<body id="home">
<form method="post" action="/?cms_mode=edit" id="main">
</form>
</body>
then a js file edit.js
should be added into head, otherwise not.
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="main.js"></script>
<script type="text/javascript" src="edit.js"></script>
</head>
Is it possible through jquery/javascript?
And edit.js flie should be added after all other .js file
Only if form
action is /?cms_mode=edit
<body id="home">
<form method="post" action="/?cms_mode=edit" id="main">
</form>
</body>
then a js file edit.js
should be added into head, otherwise not.
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="main.js"></script>
<script type="text/javascript" src="edit.js"></script>
</head>
Is it possible through jquery/javascript?
And edit.js flie should be added after all other .js file
Share Improve this question asked Sep 3, 2010 at 12:03 Jitendra VyasJitendra Vyas 153k240 gold badges587 silver badges868 bronze badges 2- 1 Why don't you handle this on the server-side? – Daniel Vassallo Commented Sep 3, 2010 at 12:04
- because i don't have those rights. i need this for particular site on multi-site CMS – Jitendra Vyas Commented Sep 3, 2010 at 12:05
1 Answer
Reset to default 5If you have to do it on the client-side in JavaScript, you may want to try the following:
var newScript;
if (document.getElementById('main').action.indexOf('?cms_mode=edit') >= 0) {
newScript = document.createElement('script');
newScript.type = 'text/javascript';
newScript.src = 'edit.js';
document.getElementsByTagName("head")[0].appendChild(newScript);
}