Is this possible?
Under the head tag to change title, meta, etc whilst in the body (but i doubt this would be SEO oriented).
Refer to http://www.daniweb.com/forums/post759748.html#post759748
Thanks, Regards X
Is this possible?
Under the head tag to change title, meta, etc whilst in the body (but i doubt this would be SEO oriented).
Refer to http://www.daniweb.com/forums/post759748.html#post759748
Thanks, Regards X
Short answer: yes — browsers let JavaScript running in the body modify head children (title, meta tags, link tags, etc.), but doing so is not a reliable replacement for server-generated metadata when you need consistent SEO or correct social previews.
raised the right concern about unique descriptions per page, and was on the right track advocating server-side assembly for predictability. Client-side DOM updates are useful for dynamic state (changing the title to show a dialog or updating meta for client-only routing), but for crawlable, shareable metadata prefer server-side rendering, build-time rendering, or prerendering.
Example (client-side mutation — works in the browser but not guaranteed for indexing or social scrapers):
document.title = "New page title";
let meta = document.querySelector('meta[name="description"]');
if (meta) {
meta.setAttribute('content', "New description");
} else {
meta = document.createElement('meta');
meta.name = "description";
meta.content = "New description";
document.head.appendChild(meta);
} For SEO: Google does execute JavaScript and can pick up some runtime changes, but rendering is delayed and not all crawlers or social bots run JS. For stable results, render unique head content server-side (or use SSR/prerender) and verify with the Google Search Console URL Inspection. Further reading: Document.title on MDN and Google JavaScript SEO basics.
Jump to Post— somedude3488 228i think you would need a server side language to accomplish what you are looking for. i really don't think javascript can change this, but you never know. i did this for my current project and its very nice. being able to change the title anywhere in a script, add …
Jump to Post— somedude3488 228i really didn't understand your last post. can you explain your problem?
i think you would need a server side language to accomplish what you are looking for. i really don't think javascript can change this, but you never know. i did this for my current project and its very nice. being able to change the title anywhere in a script, add javascript only when its needed, and dynamically add css is awesome.
i made a 4 class system. head, body, css, and the main class that brings the others together.
it builds the head content after the php has been executed and outputs it to the browser at the end.
Ya I understand that BUT what happens if you want to use those files for seperate pages for individual unqiue descriptions as in the heads...
You cant your not going to make x4 for every single page, hence is there anyother possible way...
i really didn't understand your last post. can you explain your problem?
In short I wish to redine the title, meta, etc whilst inside the body?
That better?
not really since its almost the same thing you said in the beginning. i was confused by the "unique description" and the "You cant your not going to make x4 for every single page". can you explain those better.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.