Created
July 12, 2016 06:42
-
-
Save ryan5500/d41a441b9193bccce16a55776c093cd7 to your computer and use it in GitHub Desktop.
サードパーティJavaScriptの引数処理
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* <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