Skip to content

Instantly share code, notes, and snippets.

@ideacco
ideacco / gist:f2b2a1a9aa7a49b71aeb1e7b080ea6f9
Last active October 9, 2019 03:34
根据给出的椭圆形长宽值求椭圆的周长
function yuan (a,b){
let c=(a+b)*3
let d= (3*a+b)*(a+(3*b))
let e = Math.sqrt(d)
let f= c-e
return Math.PI * (f/2)
}
// 参考链接 https://zh.wikipedia.org/wiki/%E6%A4%AD%E5%9C%86
<ul uk-tab uk-switcher="animation: uk-animation-fade">
<li><a href="#">
<h3>Changelog</h3>
</a></li>
<li><a href="#">
<h3>Planned</h3>
</a></li>
</ul>
<ul class="uk-switcher uk-margin">
<li>
//原始网站区域
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-104793185-3', 'auto');
ga('send', 'pageview');
//使用官方推荐方法获取 Gid
ga(function(tracker) {
var clientId = tracker.get('clientId');
console.log('old:',clientId)
});
//使用读取cookie的方法获取gid
var Get_gid = function getCookie(c_name){
    if (document.cookie.length>0){
//原始网站区域
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-104793185-3', 'auto');
ga('send', 'pageview');
@ideacco
ideacco / index.html
Last active August 6, 2019 10:15
获取 iframe 父级窗口并添加 JS
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<div style="width: 200px;height: 400px;background-color: blue"><button onclick="test()">点击触发</button><h2>子页面效果</h2></div>
<script type="text/javascript">
var scriptURL = 'https://www.googletagmanager.com/gtag/js?id=UA-104793185-3';