ํฐ์คํ ๋ฆฌ ๋ธ๋ก๊ทธ 2์ฐจ ๋๋ฉ์ธ ์ฌ์ฉ์ ๋๊ธ ์ค๋ฅ ๋ฌธ์ ํด๊ฒฐ ๋ฐฉ๋ฒ
๋ฐํ์ผ: 2024. 11. 20.
ํฐ์คํ ๋ฆฌ 2์ฐจ ๋๋ฉ์ธ ๋๊ธ ์ค๋ฅ ํด๊ฒฐ
๋๊ธ ์ค๋ฅ ์์ ํ๋ ๊ฐ๋จํ ๋ฆฌ๋ค์ด๋ ํธ ์ฝ๋ ์ ์ฉ ๋ฐฉ๋ฒ
ํฐ์คํ ๋ฆฌ ๋ธ๋ก๊ทธ์์ 2์ฐจ ๋๋ฉ์ธ์ ์ฌ์ฉ์ค์ด๋ผ๋ฉด ๋๊ธ ์ค๋ฅ๊ฐ ๋ฐ์ํ ์ ์์ต๋๋ค. ๋๊ธ ์ ๋ ฅ์ ํฐ์คํ ๋ฆฌ ๋ธ๋ก๊ทธ์ ๋ก๊ทธ์ธ ์ํ์์๋ ๋๊ธ ์ ๋ ฅ์ ๋ก๊ทธ์ธ ์๋ฌ๊ฐ ๋ฐ์ํ๋ ๊ฒฝ์ฐ ์ ๋๋ค. ์ด๊ฒฝ์ฐ๋ ๊ฐ๋จํ 2์ฐจ ๋๋ฉ์ธ์์ 1์ฐจ ๋๋ฉ์ธ์ผ๋ก ๋ฆฌ๋ค์ด๋ ํธ ํด์ฃผ๊ฒ ๋๋ฉด ๋๊ธ ์ ๋ ฅ์ ๋ถํธํจ์ ํด์ํ ์ ์์ต๋๋ค.
ํฐ์คํ ๋ฆฌ ๋ธ๋ก๊ทธ์์ 2์ฐจ ๋๋ฉ์ธ์ ์ฌ์ฉ ์ค์ผ ๋ ๋ฐ์ํ ์ ์๋ ๋๊ธ ์ค๋ฅ ๋ฌธ์ ์ ๋ํด ์ค๋ช ๋๋ฆฌ๊ฒ ์ต๋๋ค.
๋๊ธ ์ค๋ฅ ์๋ ๋ฆฌ๋ค์ด๋ ํธ๋ก ํด๊ฒฐ๋ฒ
์ด ๋ฌธ์ ๋ฅผ ํด๊ฒฐํ๋ ๋ฐฉ๋ฒ์ ๊ฐ๋จํฉ๋๋ค. 2์ฐจ ๋๋ฉ์ธ์์ 1์ฐจ ๋๋ฉ์ธ์ผ๋ก ๋ฆฌ๋ค์ด๋ ํธํ๋ ๋ฐฉ๋ฒ์ ์ ์ฉํ๋ฉด ๋๊ธ ์์ฑ ์ ๋ฐ์ํ๋ ๋ก๊ทธ์ธ ์ค๋ฅ๋ฅผ ์ฝ๊ฒ ํด๊ฒฐํ ์ ์์ต๋๋ค. ๋ฆฌ๋ค์ด๋ ํธ ๊ธฐ๋ฅ์ ํ์ฉํ๋ฉด, ์ฌ์ฉ์๊ฐ ๋๊ธ์ ์์ฑํ๋ ค ํ ๋ ํฐ์คํ ๋ฆฌ์ ๋ฉ์ธ ๋๋ฉ์ธ์ผ๋ก ์ด๋ํ๋ฉด์ ๋๊ธ ์์ฑ์ด ์ํํ๊ฒ ์ด๋ฃจ์ด์ง๋๋ก ํ ์ ์์ต๋๋ค.
๋ธ๋ก๊ทธ ๋๊ธ ๋ฌธ์ ๊ด๋ฆฌ ๋งคํฌ๋ก ์ ์ต๋ช ๋๊ธ ์ต์ ํ ๋ฌธ์
ํจ๊ณผ์ ์ธ ๋ธ๋ก๊ทธ ๋๊ธ ํํฐ๋ง๊ณผ CSS ์์ ์ผ๋ก SEO ๋ฌธ์ ํด๊ฒฐํ๊ธฐ๋ธ๋ก๊ทธ ๋๊ธ ๋ฌธ์ ๋ธ๋ก๊ทธ ๋๊ธ ๋ฌธ์ ๊ด๋ฆฌ๋ ์ด๋ ต๊ณ ์คํธ๋ ์ค๋ฅผ ์ ๋ฐํ ์ ์๋ค. ๋๊ธ์ด ๋ง๊ฑฐ๋ ์ ์ผ๋ฉด ๋ฌธ์ ๊ฐ ๋๋ฉฐ, ๋งคํฌ๋ก ๋๊ธ๊ณผ
everydayhub.tistory.com
๋๊ธ ๋ฆฌ๋ค์ด๋ ํธ ์ฝ๋ ์ค๋ช
id="login-guide"
: ์ด HTML ์์๋ ์ฌ์ฉ์๊ฐ ๋๊ธ์ ์์ฑํ๋ ค๋ฉด 1์ฐจ ๋๋ฉ์ธ์ผ๋ก ๋ฆฌ๋ค์ด๋ ํธํด์ผ ํ๋ค๋ ์๋ด ๋ฉ์์ง๋ฅผ ํ์ํฉ๋๋ค. ํด๋ฆญ ์ ๋ฆฌ๋ค์ด๋ ํธ ๊ธฐ๋ฅ์ด ์คํ๋ฉ๋๋ค.- redirectToTistory() ํจ์: ์ด ์๋ฐ์คํฌ๋ฆฝํธ ํจ์๋ ํ์ฌ ํ์ด์ง์ ๊ฒฝ๋ก๋ฅผ ๊ฐ์ ธ์ ํฐ์คํ ๋ฆฌ์ ๋ฉ์ธ ๋๋ฉ์ธ(1์ฐจ ๋๋ฉ์ธ์ผ๋ก ๋ฆฌ๋ค์ด๋ ํธํฉ๋๋ค. ๋ฆฌ๋ค์ด๋ ํธ ํ ์ฌ์ฉ์๋ ๋ก๊ทธ์ธ ์ํ์์ ๋๊ธ์ ๋จ๊ธธ ์ ์์ต๋๋ค.
๋ฒํผ์ ํ์ฉํ ๋๊ธ ์ฝ๋
์: ๋๊ธ ์๋ด๊ธ์ ํด๋ฆญํ๋ฉด ๋ฆฌ๋ค์ด๋ ํธ ํ๋ ์ฝ๋
<!-- ๋๊ธ ๋ฆฌ๋ค์ด๋ ํธ -->
<div id="login-guide" onclick="redirectToTistory()">
<p>ํฐ์คํ ๋ฆฌ ์์ด๋๋ก ๋๊ธ์ ๋จ๊ธฐ์๋ ค๋ฉด</p>
<p>์ฌ๊ธฐ๋ฅผ ๋๋ฌ์ฃผ์ธ์!</p>
</div>
<script type="text/javascript">
// redirectToTistory ํจ์ ์ ์
function redirectToTistory() {
// ํ์ฌ ํ์ด์ง์ URL๊ณผ targetURL์ ํฉ์ณ ์๋ก์ด URL์ ์์ฑ
var targetURL = '1์ฐจ ๋๋ฉ์ธ ์ฃผ์' + document.location.pathname + '#login-guide';
// ์๋ก์ด URL๋ก ํ์ด์ง๋ฅผ ๋ฆฌ๋ค์ด๋ ํธ
window.location.href = targetURL;
}
</script>
๋๊ธ๋์ ํ์ฉํ ๋๊ธ ์ฝ๋
์: ๋๊ธ์ ์ ๋ ฅํ๋ ค๊ณ ๋๊ธ๋์ ํด๋ฆญํ๋ฉด ์๋ ๋ฆฌ๋ค์ด๋ ํธ ํ๋ ์ฝ๋
<script type="text/javascript">
var redirectionDone = false;
document.addEventListener('DOMContentLoaded', function () {
setTimeout(async function () {
const observer = new MutationObserver(async function () {
const editableDiv = document.querySelector('.tt-box-textarea .tt-inner-g .tt-cmt');
if (editableDiv) {
editableDiv.textContent = '๋๊ธ๋์ ํด๋ฆญํ๋ฉด ์๋์ผ๋ก ํฐ์คํ ๋ฆฌ๋ก ๋ก๊ทธ์ธ๋ฉ๋๋ค';
editableDiv.addEventListener('click', async function () {
editableDiv.textContent = '';
if (!redirectionDone) {
await redirectToTistory();
redirectionDone = true;
}
});
observer.disconnect();
}
});
observer.observe(document.body, { childList: true, subtree: true });
}, 100);
});
async function redirectToTistory() {
try {
const pcViewMetaTag = document.querySelector('meta[property="article:pc_view_url"]');
if (pcViewMetaTag) {
const pcViewUrl = pcViewMetaTag.getAttribute('content');
const domainOnly = pcViewUrl.match(/^https?:\/\/[^\/]+/)[0];
const currentPath = window.location.pathname;
const targetURL = domainOnly + currentPath + '#login-guide';
window.location.href = targetURL;
} else {
console.error('Meta tag not found');
}
} catch (error) {
console.error('Error during redirection:', error);
}
}
</script>