jQuery Remove part of the HTML and append new HTML
We have approval with our client, just a heads up to cover me in any way.
We are needing to modify some of the code in a clients site if a cookie is
seen on their computer, the client's site is in ASPX format. I have the
first part of the code created, but where I am getting stuck is this:
I need to remove the last 2000 characters (or so) of the body of the page,
then append the new HTML to it.
I tried:
$('body').html().substring(0, 10050)
but that doesn't work, I also tried copying that HTML (which did work) and
put it back with the new code, but it created a loop of the script
running.
Any suggestions on what I should do? It has to be javascript/jQuery sadly.
//////// EDIT ////////////
My script is brought in by Google Tag Manager, and added to the page at
the bottom, then my script runs, this is what was causing the loop in the
script. Basically, here is the setup:
My Script on my server is loaded into the client site using Google Tag
Manager, added to the bottom of the page. From there it is able to
execute, but when doing this, it creates a loop of adding the Google Tag
Manager script, causing my code to re-add, causing it to re-execute again.
The client is not willing to do anything, he has pretty much told us to
just figure it out, and to not involve his web guy.
No comments:
Post a Comment