HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<h1>Hackle JavaScript SDK 연동 및 기능 적용 예제</h1>
<div style="padding: 5px">
<label for="uname">사용자 식별자를 입력하고 테스트 그룹 분배 버튼을 눌러주세요.</label><br><br>
<input type="text" id="uname" name="uname">
<input type="button" value="테스트 그룹 분배" onClick="FuncHackleSdk()">
</div>
<div style="padding: 5px" id="bgcolor">
<p id="result"><i>분배 수행 후 여기에 분배 결과가 나타납니다.</i></p>
<p id="reason"></p>
</div>
/***************************************
여러분의 워크스페이스로 테스트하려면
SDK 키, 실험 키 값을 수정해야 합니다.
이벤트 키는 수정하지 않아도 됩니다.
***************************************/
// SDK 키
HACKLE_SDK_KEY = "0wXYq7fkt1wnthsG5kmO2c3SKAI98PIh";
// 실험 키
const experimentKey = 9;
// 이벤트 키
const eventKey = "hackle_test_event_key";
/***************************************
수정하지 마세요! - Hackle SDK 연동
***************************************/
!function(e,t){var n,a=3e3,c=!1,l=[];function r(){}r.prototype.onReady=function(e,t){var n={block:e,timeout:t};l.push(n)},r.prototype.setUserId=function(e){n=e},e.Hackle=e.Hackle||new r,e.hackleClient=e.hackleClient||new r;var o=setInterval(function(){if(c){clearInterval(o);for(var t=0;t<l.length;t++)
e.hackleClient.onReady(l[t].block,l[t].timeout);l.length=0}(a-=50)<0&&clearInterval(o)},50),i=t.createElement("script");i.type="text/javascript",i.crossOrigin="anonymous",i.src="https://cdn.jsdelivr.net/npm/@hackler/js-client-sdk@2.0.0/lib/umd/hackle-js-client-sdk.min.js",
i.async=!0;var s=t.getElementsByTagName("script")[0];s.parentNode.insertBefore(i,s),i.onload=function(){c=!0,e.Hackle=Hackle,n&&Hackle.setUserId(n),e.hackleClient=Hackle.createInstance(HACKLE_SDK_KEY)},i.onerror=function(){clearInterval(o)}}(window,document);
/********************************
테스트 그룹 분배 버튼을 누를 때 호출
********************************/
function FuncHackleSdk() {
// 입력된 사용자 식별자 가져오기
var userId = document.getElementById("uname").value;
// 사용자 식별자가 입력되지 않은 경우 경고
if (userId == "") {
alert("사용자 식별자를 입력해주세요.");
return;
}
// SDK 전송을 위한 포맷으로 변경
var user = { id: userId };
/**************************
SDK 기능 1. 테스트 그룹 분배
**************************/
const decision = hackleClient.variationDetail(experimentKey, user);
const variation = decision.variation;
const reason = decision.reason;
// 분배 결과에 따라 다른 결과를 보여준다
if (variation.toString() == "A") {
// 테스트 그룹 A에 보여줄 화면 or 기능 or 로직
document.getElementById("bgcolor").style.backgroundColor = "#FFCCFF";
document.getElementById("result").innerHTML = userId + "의 테스트 그룹 분배 결과는 <b><font color=\"red\">대조군(테스트 그룹 A)</font></b>입니다.";
document.getElementById("reason").innerText = "* 분배 사유: " + reason;
}
else if (variation.toString() == "B") {
// 테스트 그룹 B에 보여줄 화면 or 기능 or 로직
document.getElementById("bgcolor").style.backgroundColor = "#99CCFF";
document.getElementById("result").innerHTML = userId + "의 테스트 그룹 분배 결과는 <b><font color=\"blue\">실험군(테스트 그룹 B)</font></b>입니다.";
document.getElementById("reason").innerText = "* 분배 사유: " + reason;
}
else {
// 테스트 그룹 분배 결과에 오류가 있을 경우
document.getElementById("result").innerHTML = "테스트 그룹 분배 중 오류가 발생했습니다.";
}
/**********************************
SDK 기능 2. 사용자 이벤트 전송
**********************************/
hackleClient.track(eventKey, user);
alert("사용자 이벤트를 전송하였습니다.\neventKey = " + eventKey);
}
Also see: Tab Triggers