How to generate code in the javascript div

Asked

Viewed 695 times

0

I wanted to know how to put a code html in a tag div using `javascript

I would also like an explanation on how to redirect someone to my page if someone removes my id from the page, I’ve seen it before, designers create themes and put so that users do not remove credits...

  • 2

    Ever thought of hiring a developer to do this for you?

  • 1

    "Designers create themes and place so that users do not remove credits."Usually this is done by kids who encode a redirect script with Base64, escape of characters, or something like that, just to be curious not to copy. In practice, it does not work for anything, because it is extremely simple to remove. Suggestion: do not waste time with these silly things.

3 answers

4

document.getElementByClassName('Creditos').innerHtml('codigo html aqui');

I imagine you want if someone copies your source code and remove the credit it identifies and redirects to your page, starting from the assumed pre that the person will not remove the code that does this.

It would be something like that:

if(!document.getElementByClassName("Creditos")){
    window.location = "http://www.suapagina.com.br";
}

1


You can do so with jQuery: http://codepen.io/anon/pen/grxLjG

$(document).ready(function() {
  var elemento = $('#Creditos');
  if (elemento.length > 0) {
    elemento.text('Seu texto vai aqui');
  } else {
    window.location = 'http://github.com';
  }
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="Creditos"></div>

1

Good morning, simple, you can do it like this:

<div id="Creditos"></div>

ai no JS:

var Teste = {

init: function(){

    var label = document.createElement('label');
    label.setAttribute("class", "classe_do_label");
    label.innerHTML = "Teste Label";

    document.getElementById('creditos').appendChild(label);
}};
window.onload = Teste.init();

In this example I created a label in JS I added a class in it and added the test label text and inserted it into html by JS itself.

Hope I helped, hugs

;)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.