Languages :: DHTML, JScript :: How do I rewrite the layout of a web page by injecting javascript? |
|||
| By: Roald |
Date: 25/09/2008 21:41:17 |
Points: 20 | Status: Answered Quality : Excellent |
|
We have a web page run by a 3rd party which give us very little ability to change the layout of the page. We have a CMS-like web interface to edit news items and add translations to the page, but apart from that we can not easily change much else than the font size. Asking for changes from the provider takes both a lot of time and money. However, we can edit the text on each of the sub pages using the built-in editor, and these fields allow HTML tags. That is how I got the idea of rewriting the full layout using javascript. The problem is that I don't know where to start. Google searches give very few results. I suspect reading about the DOM (document.getElementById and such commands?) is quite important, but how should I start? E.g. if I want to change the title tag and put my own CSS in the head of the HTML. Will every update require me to write everything manually, or can I design the layout in e.g. Dreamweaver and then easily convert it to my injected javascript tag? (All code will go in these text fields, no loading of external .js files because a SSL site will give "non-secure elements" warnings.) |
|||
| By: VGR | Date: 25/09/2008 22:01:32 | Type : Answer |
|
| okayyy bad luck, huh ? ;-) Well, you have a problem. You can't afford to reprogram the whole site so that you've control over the layout, and you can't afford to ask for so many modifications. It's true that using JScript you may (using the DOM and getElementById, getElementByTagName and such, you're right) change the contents (you don't need this, you've your CMS) and the layout. The most obvious solution to your problem would be : ask for control over the CSS file(s). If the site was properly designed, you can entirely change the layout from there. It's only one file (or a few files). You should ask for an sFTP access or - given it's already an HTTPS site - for a secured access to that file too. The less obvious solution to your problem is to modify the text elements to include DOM objects manipulations, inline CSS on the HTML tags and such. Very difficult. Try to get solution#1 As a side note, if I were you, I would first check the contract to see if you have or don't have ownership on the whole website (given you're the customer and paid for it), including the scripts source code, layout, logos and layout... If yes, ask for the whole. If not, menace to end the contract if they don't become more reactive and cost-effective to your needs. (the relationship seems quite spoiled already) In either case, think to ask a concurrent to make a quote to port the website on a system you will control/have access to. I even ported websites when my customer did not have any source code access (same case as you if you're unlucky ;-), so I kept the layout (just save the webpages as complete files) and reprogrammed all the functions. Now my customer is happy. Too bad I don't have time for this any more, I love doing this :D I'm sure you'll find skills to do so... For a start, just ask some of their concurrents 8-)) good luck... |
|||
| By: Roald | Date: 19/11/2008 13:24:55 | Type : Comment |
|
| Thank you for your answer. If it ever is done, it will be done by parsing the HTML with a PHP script. | |||
|
Do register to be able to answer |
|||
©2010 These pages are served without commercial sponsorship. (No popup ads, etc...). Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE.
Please DO link to this page!








