How to place a banner on webpage with one application to all pages of a website

非 Y 不嫁゛ 提交于 2019-12-10 22:22:45

问题


How can I place a banner on webpage with one application to all pages of a website?


回答1:


One way of doing this is to put your banner into a file, then include that one on each of your other pages. This way, you only have to change the code in one place to update the banner site-wide.

So, a PHP example would be:

banner.inc.php:
<?php
  // echo out banner here...
?>

Then, on your other pages:

include("banner.inc.php");



回答2:


You can just create a header file that you include in all your pages, and include the banner code in it. The solution is pretty much the same in all languages. If your host allows server-side includes, you can even do exact same thing with (nearly) pure HTML. You can also do it with JavaScript pretty easily.




回答3:


Do you have a global template for all your pages? Something where the basic structure of all your pages is defined while the specific stuff is filled into parts of the body? If you had something like this you could modify the global template to have the banner you want and it would show on all your pages.

Google "html templating" for more.




回答4:


I recommend using master pages. That way if you have something that has to be changed globally across the project you only have to change it in one place. And they are really simple to use.




回答5:


If your web server is IIS, and you know a smidge of CSS you can do this without perl, without touching any other files, but at the cost of some performance.

IIS allows you to insert an HTML snippet into anything served: http://www.microsoft.com/technet/prodtechnol/WindowsServer2003/Library/IIS/e27f918e-89a9-45a8-8604-2ad2ded09d64.mspx?mfr=true

If said footer file, had CSS which shoved it to the top, then you would get the behavior you are looking for.

Please note, that this is NOT an ideal solution, but it is a quick and dirty patch until you can go back and retrofit all of your pages with a master page or something similar.




回答6:


If it really should be on every page of your site, I'd argue that it's part of the site design rather than the content itself. In this case, you are easily justified in setting a background-image in your css. Of course, you probably then still have to have some sort of place-holder element in your html, but at least you could update the whole site together.




回答7:


Well, hopefully you would have designed the website so that if you need to change something globally, you can just edit a header or footer file.

If not, I would use Perl to go through all the files, and do a search and replace.



来源:https://stackoverflow.com/questions/400631/how-to-place-a-banner-on-webpage-with-one-application-to-all-pages-of-a-website

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!