Gaurav_soni
Gaurav_soni

Reputation: 6114

Jquery not loading script tags to load libraries

i have a html page where i am creating a new window.

var newwindow = window.open();
      $(newwindow.document.head).load('/Viewer/html/imageLibraries.html');
      $(newwindow.document.body).html("<h1>Its  a new page :D</h1>") ;

My imageLibraries.html is like this

<meta charset="utf-8">
<link href="../css/new_kendo.css" rel="stylesheet">
<link href="../css/style.less" rel="stylesheet/less">

<script type="text/javascript" src="Viewer/libs/angular.min.js"></script>
<script type="text/javascript" src="Viewer/libs/less.js"></script>
<script type="text/javascript" src="Viewer/libs/jquery-1.8.3.min.js"></script><!--JQuery library-->
<script src="Viewer/libs/jquery-ui.min.js"></script><!--Jquery library -->
<script src="Viewer/libs/ImageViewer.js"></script><!--JQuery library for Imageviewer-->

<script src="Viewer/libs/kendo.all.min.js"></script><!--For Kendo Functionality -->

<script src="Viewer/libs/jquery.mousewheel.js"></script><!--JQuery library for use mouse event-->
<script src="Viewer/js/app.js"></script>

<script src="Viewer/js/directives/directives.js"></script><!--directive for iviewer-->

The problem is, the css files are loading fine but the script tags are not loading In the console the DOM tree is like this

<head><meta charset="utf-8">
<link href="../css/new_kendo.css" rel="stylesheet">
<link href="../css/jquery.iviewer.css" rel="stylesheet">
<link href="../css/style.less" rel="stylesheet/less">



<!--JQuery library-->
<!--Jquery library -->
<!--JQuery library for Imageviewer-->

<!--For Kendo Functionality -->

<!--JQuery library for use mouse event-->


<!--directive for iviewer--></head>

Can someone suggest what to do ?

Upvotes: 0

Views: 59

Answers (2)

Radonirina Maminiaina
Radonirina Maminiaina

Reputation: 7004

It runs, maybe, the problems come from your url.

$(newwindow.document.head).load('Viewer/html/imageLibraries.html');

In my local I do:

$(newwindow.document.head).load('imageLibraries.html');

And it loads both javascript and css. Image here

Upvotes: 1

JohnDevelops
JohnDevelops

Reputation: 567

The issue is probably to do with the use of .load()?

https://api.jquery.com/load/

Script Execution

When calling .load() using a URL without a suffixed selector expression, the content is passed to .html() prior to scripts being removed. This executes the > script blocks before they are discarded. If .load() is called with a selector > expression appended to the URL, however, the scripts are stripped out prior to > the DOM being updated, and thus are not executed.

Upvotes: 1

Related Questions