Where to copy this code

Hello, I start with a theme in html5 and I do not know where to copy this code. I have 3 javascript files … I do not know which to choose?
My javascript files :
bootstrap.js, bootstrap.min.js and jquery-1.11.0.js

<script type="text/javascript">
	/*  The code below cannot be used together, use solution 1 or solution 2  */
	//  Solution 1
		    $(this).attr('target', '_blank');
	}); </script>


Should we copy the entire code or just:

		    $(this).attr('target', '_blank');

Thank you for your help

I have 3 javascript files … I do not know which to choose?

either of the bootstrap ones plus jQuery (Bootstrap depends on jQuery).

Should we copy the entire code or just:

it depends where you want to use it. JavaScript in external files must not use <script> tags as those files must only contain JavaScript code.

Hello Dormilich, thank for your help, I create another link.js file and put this code:

		    $(this).attr('target', '_blank');

and put this code in my page html:

 <!-- jQuery Version 1.11.0 -->
    <script src="js/jquery-1.11.0.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>
	<!-- lien -->
    <script src="js/link.js"></script>

it is not working.

Bootstrap.js and jQuery its complicated for me and I would not crash my site … could you help me to define where to embed the code?

This is the end of bootstrap.js :

  // ==============

  $(window).on('load', function () {
    $('[data-spy="affix"]').each(function () {
      var $spy = $(this)
      var data = $spy.data()

      data.offset = data.offset || {}

      if (data.offsetBottom) data.offset.bottom = data.offsetBottom
      if (data.offsetTop)    data.offset.top    = data.offsetTop

      Plugin.call($spy, data)


This is the end of jquery-1.11.0.js :

...void 0===d?n.css(b,c,g):n.style(b,c,d,g)},b,f?d:void 0,f,null)}})}),n.fn.size=function(){return this.length},n.fn.andSelf=n.fn.addBack,"function"==typeof define&&define.amd&&define("jquery",[],function(){return n});var fd=a.jQuery,gd=a.$;return n.noConflict=function(b){return a.$===n&&(a.$=gd),b&&a.jQuery===n&&(a.jQuery=fd),n},typeof b===L&&(a.jQuery=a.$=n),n});

thank you again

it is not working.

well, nothing we can really do something about. you’d have to post the error message you get in the error console (F12).

I is not an error message. The link opens normally but in the same window.

then my best guess is that the selector for the links didn’t match.

Hi gwenm,

I have updated the previous “Code will not validate wc3” thread and the links now open in a new window.

There are two different version, with and without using jQuery (jQuery must be included before your own JavaScript).


Source code is show at the bottom of the page.

Hi John, if I understand correctly, I do not need to create a .js file, I just have to add the code in the page? It’s that?

Yes, try this:

  <a href='http://osric.net/' onclick='window.open("http://osric.net"); return false;'>
   Open in new window: osric.net web hosting

ok! Thank you very very much John! your very very nice…it is a real pleasure :for_you:
Thank you also Dormilich :wink: