 |
| Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more. |
|
 |
01-09-2007, 09:58 PM
|
#1 (permalink)
|
|
Junior Member
Join Date: 08-01-06
Posts: 16
Latest Blog: None
|
how do i create a javascript code that allows me to add links
How do i create a javascript code that allows me to add links from 1 place to a bunch of other places. Like what google adsense does.
sorry if this question dosen't make sense but I couldn't fiqure out another way to word it.
kf9211
|
|
|
01-10-2007, 12:12 PM
|
#2 (permalink)
|
|
v7n Mentor
Join Date: 11-01-03
Location: Kansas City
Posts: 1,330
|
Hmm.. I'm a little confused at to what you are saying.
So, you're saying, transferring links from 1 page to another?
__________________
█ Izzmo
█ Coding Guru Extraordinaire
█ ZeroWeb Hosting & Design - Customizable hosting for every type of user!
|
|
|
01-21-2007, 07:09 PM
|
#3 (permalink)
|
|
Junior Member
Join Date: 08-01-06
Posts: 16
Latest Blog: None
|
kind of what I want to do is make it so that if i add a link to every page of my website I don't have to do it to every page manualy
thank you
kf9211
ps. it dosen't have to be javascript I just thought that that would be what you would use to do that but now that I think about it it would probably be rss or something else
|
|
|
01-21-2007, 07:25 PM
|
#4 (permalink)
|
|
Senior Member
Join Date: 01-02-07
Location: PA, USA
Posts: 191
Latest Blog: None
|
So like an include of them on every page, sort of along the idea of the stuff on the left side on this => http://doumc.com ? if so just create the html page and then in PHP include("name.html"); or require, or include_once or require_once whatever. I'm not sure what the equivalent of an include function is in JS though.
|
|
|
01-21-2007, 08:00 PM
|
#5 (permalink)
|
|
Junior Member
Join Date: 08-01-06
Posts: 16
Latest Blog: None
|
how would i include ("name.html") in php
|
|
|
01-21-2007, 08:49 PM
|
#6 (permalink)
|
|
Senior Member
Join Date: 01-02-07
Location: PA, USA
Posts: 191
Latest Blog: None
|
PHP Code:
<?php include("name.html"); ?>
of course your file doesn't have to be name.html it can be anything.
|
|
|
01-22-2007, 10:02 AM
|
#7 (permalink)
|
|
v7n Mentor
Join Date: 04-07-06
Location: Manchester, NH
Posts: 722
|
As above, plus, you can't do that in javascript unless you set javascript as a server side language which I've never seen done. Pages (with your links) are served by the server.
The server downloads html and javascript to the browser. The browser / html / javascript may not write to the server. The html and javascript send server requests, and the server carries them out. So you have to have a server side language to process the request.
browser (client) asks for web page
Server (IIS, Apache, whatever) sends html and/or javascript to browser(client)
User inputs links into browser, submits
Form submitted sends request "please add these links" and data (the links the user input) to server
The server hands off request to server side processor (php, asp, whatever)
The processor receives link strings, adds them to some file your site will display, hands control back to the server
Server sends "thanks for your links, we're working on it" back to the client.
|
|
|
01-23-2007, 10:18 AM
|
#9 (permalink)
|
|
Contributing Member
Join Date: 07-30-05
Posts: 247
Latest Blog: None
|
Quote:
Originally Posted by CarolineBogart
As above, plus, you can't do that in javascript unless you set javascript as a server side language which I've never seen done. Pages (with your links) are served by the server.
|
Granted JS is CLIENT side, not SERVER side. But, why cant you have in a JS file:
Code:
<html>
<head>
<title>V7N</title>
</head>
<body>
<script src="links.js" language="javascript" type="text/javascript"></script>
</body>
</html>
Code:
document.write("<a href='link1.htm'>Link 1</a><br />");
document.write("<a href='link2.htm'>Link 2</a><br />");
document.write("<a href='link3.htm'>Link 3</a><br />");
From here you will need the
Code:
<script src="links.js" language="javascript" type="text/javascript"></script>
in every page's nav section
Edit "links.js" as needed....
|
|
|
01-23-2007, 01:58 PM
|
#10 (permalink)
|
|
v7n Mentor
Join Date: 04-07-06
Location: Manchester, NH
Posts: 722
|
Quote:
Originally Posted by Radnor
Granted JS is CLIENT side, not SERVER side. But, why cant you have in a JS file:
Code:
<html>
<head>
<title>V7N</title>
</head>
<body>
<script src="links.js" language="javascript" type="text/javascript"></script>
</body>
</html>
Code:
document.write("<a href='link1.htm'>Link 1</a><br />");
document.write("<a href='link2.htm'>Link 2</a><br />");
document.write("<a href='link3.htm'>Link 3</a><br />");
From here you will need the
Code:
<script src="links.js" language="javascript" type="text/javascript"></script>
in every page's nav section
Edit "links.js" as needed....
|
Cool, I must have misunderstood the requirement.
I thought you wanted to accept an input from the user that would write the links to a file. If you've already got the links than this or the include(name.htm) above will work as well.
|
|
|
01-23-2007, 02:20 PM
|
#11 (permalink)
|
|
Contributing Member
Join Date: 07-30-05
Posts: 247
Latest Blog: None
|
Quote:
Originally Posted by CarolineBogart
I thought you wanted to accept an input from the user that would write the links to a file
|
NO! I would NEVER allow an outsider add links to my page. Who knows where they would send people.
This will work too if you can have server side include(s)
Code for v7n. SHTML
Code:
<html>
<head>
<title>V7N</title>
</head>
<body>
<!--#include file="links.htm" -->
</body>
</html>
code for links.htm
Code:
<a href='link1.htm'>Link 1</a><br />
<a href='link2.htm'>Link 2</a><br />
<a href='link3.htm'>Link 3</a><br />
|
|
|
01-23-2007, 06:23 PM
|
#12 (permalink)
|
|
Junior Member
Join Date: 08-01-06
Posts: 16
Latest Blog: None
|
thanks so much for helping me thats exactly what i wanted to do
|
|
|
01-23-2007, 08:47 PM
|
#13 (permalink)
|
|
Junior Member
Join Date: 08-01-06
Posts: 16
Latest Blog: None
|
wait never mind thats not what i want to do. what the problem is is that i have a website that has many pages and i have some of the links already however i plan on adding some later so instead of doing it manualy I wanted to know if there is way to make it so that you could add something like javascript or php or any other scripting language to make it so you could create a seperate page that would put that html, javascript etc. onto that page that way you would only have to change 1 page as apposed to having to change every page manualy. (also it dosen't have to be a scripting language it could also be a program that could do it.)
thank you
kf9211
|
|
|
01-23-2007, 08:51 PM
|
#14 (permalink)
|
|
v7n Mentor
Join Date: 04-07-06
Location: Manchester, NH
Posts: 722
|
The answer you seek is within you.
|
|
|
01-23-2007, 08:55 PM
|
#15 (permalink)
|
|
Junior Member
Join Date: 08-01-06
Posts: 16
Latest Blog: None
|
? umm? 
|
|
|
01-23-2007, 09:04 PM
|
#16 (permalink)
|
|
Senior Member
Join Date: 01-02-07
Location: PA, USA
Posts: 191
Latest Blog: None
|
First page name it whatever you want .txt
HTML Code:
<table><tr><td valign="top" width="180px"><a href="firstpage.html">First Page</a><br />
<a href="secondpage.asp">Second Page</a><br />
<a href="thirdpage.php">Third Page</a></td>
That will create it vertically. Make it valid as you will. width can be whatever you want, and should be defined in CSS for validity. Have td.left have the width and have it be class="left" in the td there.
Second page (the one they'll view) name it whatever you want .php
PHP Code:
<?php
echo "<html><head><title>Title</title></head><body>";
include('whateverYouNamedIt.txt');
echo "<td><p>your page content</p></td></tr></table></body></html>";
That should be how your every page is, if you're like me and just include a head and a body file you can have the body file be </td></tr></table></body></html> and the head file be <html><head><title>TITLE</title></head><body><table><tr><td>your links</td><td> then you can just write your pages as normal and just include that. If you want your links at the top tell me and I'll give you an example of how to do that.
|
|
|
01-23-2007, 09:14 PM
|
#17 (permalink)
|
|
v7n Mentor
Join Date: 04-07-06
Location: Manchester, NH
Posts: 722
|
Click the link, glasshoppah
you want the include stmt
|
|
|
01-24-2007, 07:58 AM
|
#18 (permalink)
|
|
Contributing Member
Join Date: 07-30-05
Posts: 247
Latest Blog: None
|
What program are you using to edit your pages with?
|
|
|
01-26-2007, 05:16 PM
|
#19 (permalink)
|
|
Junior Member
Join Date: 08-01-06
Posts: 16
Latest Blog: None
|
i'm not using any program to edit it i'm just using html
|
|
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 04:59 PM.
© Copyright 2008 V7 Inc Powered by vBulletin Copyright © 2000-2009 Jelsoft Enterprises Limited.
|
|
|