Sha
Sha

Reputation: 1974

Hiding third party script from particular page

i have a HTML template in which i have used a third party javascript code. this particular code provides an chat option.i have added this script in my header.html so that it gets displayed in all the pages. however i dont want this to display in my login page.i want this to be displayed only after logging in.

How do i hide this from a particular page(here login.html)?

Header.html

 <!doctype html>
 <head>
    <meta charset="utf-8">
    <link rel="stylesheet" href="bower_components/weather-icons/css/weather-icons.min.css">
    <link rel="stylesheet" href="styles/main.css">
</head>
<body data-ng-app="app" id="app" class="app" data-custom-page="" data-off-canvas-nav="" data-ng-controller="AppCtrl" data-ng-class=" {'layout-boxed': admin.layout === 'boxed' } ">
    <section data-ng-include=" 'views/index.html' " id="header" class="header-container" data-ng-class=" {'header-fixed': admin.fixedHeader} " data-ng-controller="HeaderCtrl" data-ng-intro-options="introOptions" data-ng-intro-method="startIntro" data-ng-intro-autostart="true"></section>  
    <script src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <script src="scripts/vendor.js"></script>
    <script src="scripts/jquery.leanModal.min.js"></script>
    <script src="scripts/ui.js"></script>
    <script src="scripts/app.js"></script>
    <script src="scripts/product_listing.js"></script>
    <script src="scripts/angular-cookies.js"></script> 
 <script id="SettingsScriptTag"> 
 **Third Party script Goes here**
 </script>
</body>
</html>

The above header.html is included in all the other templates. hense the thrid party script runs in login page too. I need to hide this in login page.

Upvotes: 2

Views: 780

Answers (2)

Tserkov
Tserkov

Reputation: 446

If you're using jQuery (which... I think you are...?)

$(function () {
  if (window.location.pathname !== '/login.html') {
    // Third-party script goes here
  }
});

Upvotes: 1

John
John

Reputation: 889

If Using jquery .remove() is used to remove the html elements. So you can write this script on document ready of the login page.

$(document).ready(function(){
    $( "#SettingsScriptTag" ).remove();
});

Upvotes: 0

Related Questions