Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

javascript include files

Featured Replies

Hello again!

 

Im not that familar with JS, I want to start by optimizing my site from tips from another post on this forum.

 

I have a big chuck of text on my site which calls the time and date in JS,I want to tidy this up - how would I call this with an include file from JS?

 

Your help if greatly appreciated as always!

Not sure what you're asking. You want to get the time and date in JS? Or you want to fetch text from a file in JS?

do you mean like how a css file is included in the head?

 

if yes then you would place the script in a .js file and then use this in the head:

<script type="text/javascript" src="file.js"></script>

 

 

 

 

But if you mean like a php include file because your JS is in the body, then that is done the same way as any php include file would be created and you just need to place the script into a different document and then use:

 

<?php include("js_thing.php"); ?>

 

In your HTML file

 

Well at least I would imagine that it would be as JS is client side scripting so the browsers would read it once the serverside php script had placed it into the HTML....never tried it but I can't see a reason for this not to work :p

  • Author

Sorry should have been more clear tt, Thanks dizi thats what I was after!

 

<script type="text/javascript" src="file.js"></script>

 

cheers

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.