QNimate

  • CoursesVideos
  • WP PremiumPlugins
  • DemosLab
  • Home
  • QIdea
  • QTrack
Home Carbon Ads Passing Arguments To JavaScript Files

Passing Arguments To JavaScript Files

In this post I will provide a trick to pass data to embedded JavaScript or external JavaScript files.


Passing Data

Data can be passed simply using data-* attributes in script tags.

Retrieving Data

Data can be retrieved by obtaining a reference to the script tag and then reading the data-* value. Reference to the current script can be obtained using document.currentScript property.

Jul 24, 2014Narayan Prusty
JavaScript Function Techniques You May Not KnowCSS3 Multiple Columns Example

Leave a Reply Cancel reply

To create code blocks or other preformatted text, indent by four spaces:

    This will be displayed in a monospaced font. The first four
    spaces will be stripped off, but all other whitespace
    will be preserved.
    
    Markdown is turned off in code blocks:
     [This is not a link](http://example.com)

To create not a block, but an inline code span, use backticks:

Here is some inline `code`.

For more help see http://daringfireball.net/projects/markdown/syntax

Narayan Prusty

I am a software engineer specialising in Blockchain, DevOps and Go/JavaScript. This is my personal blog where I write about things that I learn and feel interesting to share.

8 years ago Web Development
Share this
0
GooglePlus
0
Facebook
0
Twitter
0
Linkedin
  • Passing Data
  • Retrieving Data
Related Articles
  • Pull To Refresh For Phonegap App
  • Stop requestAnimationFrame
  • JavaScript “…” Operator
  • Data URI Tutorial
  • Displaying And Highlighting Source code in HTML Page
Our Sponsor
My Books

2014 - 2015 © QNimate
All tutorials MIT license