Skip to content

Instantly share code, notes, and snippets.

@ryan5500
Created July 12, 2016 06:42
Show Gist options
  • Save ryan5500/d41a441b9193bccce16a55776c093cd7 to your computer and use it in GitHub Desktop.
Save ryan5500/d41a441b9193bccce16a55776c093cd7 to your computer and use it in GitHub Desktop.
サードパーティJavaScriptの引数処理
/* <script data-stork-product-id="1234">
(function() {
//jsの読み込みコード
})();
</script> */
function getProductId() {
var scripts = document.getElementsByTagName('script');
var id;
for (var i = 0; i < scripts.length; i++) {
id = scripts[i].getAttribute9'data-stork-product-id');
if (id) { return id; }
}
return null;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment