Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
0 votes
803 views
in Q2A Core by

i tried to insert the code under the admin->Layout->Custom HTML in <HEAD> section of every page.

i have a condition that if the page is a subpage it will do this: document.getElementsByTagName('head').item(0).innerHTML+="<script type='text/javascript'>alert('Test');</scr"+"ipt>;

the code was inserted under the <head> tag but there was no alert. please help.

 

Thanks

1 Answer

+1 vote
by

That is Javascript so you need to put it inside a <script> tag itself.

<script>
document.getElementsByTagName('head').item(0).innerHTML+="<script type='text/javascript'>alert('Test');</scr"+"ipt>;
</script>

However, the code you posted is just equivalent to this:

<script type='text/javascript'>alert('Test');</script>

So you can just put that instead.

...