Search and Replace CSS or Javascript on all pages at once

Hello Rapidweaver friends,

Is there a quick way to do a “search and replace” on each page of a website all at once?

In a website that has about 300 pages, I need to replace the same a few characters in the Javascript section of each page with different characters (but similar to each other). For example, replace all the “function Name()” with “function Age()”.

Doing a “search and replace” on each page is endless.

I do place most of the CSS and Javascript in the general code section of Rapidweaver. But not all of it as each page is a bit different.

Thank you for your guidance. And if such a feature doesn’t exist yet in Rapidweaver, a cross-page search and replace feature would be a welcome addition to future versions of RW.

George

No, it’s not possible. One possible solution for the future would be to import css or javascript which might change from external files. That way, one change would affect all relevant pages.

1 Like

Does your suggestion imply that I should import 300 .js external files, for each of the 300 pages of the website?

I lack knowledge and there must be a more straightforward way to do that. Note that since I read your reply, I looked into how to add an external .js file into my server, and although I haven’t yet managed to make it work (by observing the expected effects of the javascript code onto the page), I think I will eventually find the way to do it (any tip is welcome).

Here is the javascript code I was referring to. The URL must differ from page to page (it is actually inline HTML code in Javascript):

function CopyToClipboard() {
prompt(“Embed this page to your site:”, "<iframe src=“https://player.vimeo.com/video/457049772” frameborder=“0” allowfullscreen> ");
}

I’m almost entirely ignorant of javascript but I think you ought to be able to get it to insert the url of the page itself, so you’d only need one script for all the pages. With a bit of luck some javascript guru will let you know. See https://www.w3schools.com/js/js_window_location.asp

1 Like