473,399 Members | 3,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

re links and javascript

Hi
I have an external javascript file which in included in my html file
header thus:

<script src="/style/common.js" type="text/javascript"></script>

with a function thus

/* simple new window function Adrian Suri common.js */

function loadNewPage(url) {
window.open(url);
return true;
}

now the question is how do I do a nornal href link to call this
function passing the url, note I do not want to use buttons

this does not work
<li><a
href="loadNewPage("http://groups.yahoo.com/group/Dev_Corner/files/C%20&amp;%20C++%20Training/Class%20Lessons/CPPL01NM.TXT)";
Setting up the Watcom compiler</a></li>
regards

Adrian

Feb 16 '06 #1
5 963
VK

ad********@gmail.com wrote:
Hi
I have an external javascript file which in included in my html file
header thus:

<script src="/style/common.js" type="text/javascript"></script>

with a function thus

/* simple new window function Adrian Suri common.js */

function loadNewPage(url) {
window.open(url);
return true;
}

now the question is how do I do a nornal href link to call this
function passing the url, note I do not want to use buttons

this does not work
<li><a
href="loadNewPage("http://groups.yahoo.com/group/Dev_Corner/files/C%20&amp;%20C++%20Training/Class%20Lessons/CPPL01NM.TXT)";
Setting up the Watcom compiler</a></li>


<a href="MyNoScript.html" onclick="loadNewPage('foo.html');return
false;">

Feb 16 '06 #2
wrote on 16 feb 2006 in comp.lang.javascript:
I have an external javascript file which in included in my html file
header thus:

<script src="/style/common.js" type="text/javascript"></script>


An external .js-file must not so cannot contain html, and <script.. is.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Feb 16 '06 #3
Thanks for that it work, one more question, since some of the links
are so long
is it possible to include an array of links in say an onload method
anmd then use these avalues in the function loadNewPage()

regards

adrian

sorry cannot post via my normal news server, not sure why

Feb 16 '06 #4
To reanswer your first question, I would change the link code to look
like this:

<a href="http://www.blahblahblah.com/morestuff"
onclick="loadNewPage(this.href); return false;">Click Me</a>

This solution seems a little more elegant to me. This would make it
very easy to convert normal links to use your load page function with
out changing anything else in the link. All you would have to do is
add the onclick code, and the link wouldn't break if you removed it.

As for your second question, you could certainly program your
loanNewPage to accept an array of links, but why would you want to do
this? Clarify your question please.

Feb 16 '06 #5
the idea was simply to cut down on very long href links
to make it more understandable but
loadNewPage(this.href); return false;" solves the problems for me...

Many thanks for all the help

kind regards

adrian

Feb 16 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Yvan J. Gagnon | last post by:
I am currenly developing a web site using Macromedia fireworks, and am trying to figure out a way (through hand-coding) of attaching a javascript function (onClick="doit=false") to each of the...
2
by: chris hughes | last post by:
Can anyone please tell me how to create a javascript that I can place in any page that will disable all the links or just change all the hrefs to # Many Thanks Chris Hughes
2
by: Konrad Mathieu | last post by:
Does this work in most browsers, namely MSIE? document.links.href or does it have to be document.links.href ?
9
by: chrisspencer02 | last post by:
I am looking for a method to extract the links embedded within the Javascript in a web page: an ActiveX component, or example code in C++/Pascal/etc. I am looking for a general solution, not one...
10
by: Trammel | last post by:
Hi, Im just about to start developing a new website for personal / friend use that may be accessed by other people all over the web. I was sitting thinking through designs for the pages, etc when...
1
by: nsvmani | last post by:
Hi, i am trying to get the FileOpen dialogue window as soon as clicked href link I am using IE6 with ActiveX enabled. Just need to get the File Open dialogue window when i click on the HREF links.It...
1
by: Gerald Shastri | last post by:
Hi, I have a page which is being generated by a CMS and I can't control the links which are being outputted. I want to add a target = "_parent" attribute to all the links on my page using...
0
iam_clint
by: iam_clint | last post by:
This is a list of offsite links with good information on them (if you have any links to add please pm me) Remember when looking for examples use examples from 2 or more sites if you are not sure...
2
by: learnyourabc | last post by:
For a webcrawler, you need to extract all links from the web page. For normal html anchor tags or any of the src and href attribute on the tag can be easily extracted using ihtmldocument. What...
0
by: Peter Horlock | last post by:
Hi, Using css (that should be working in Firefox 2,3 and Internet Explorer 6,7 at least), I would like to create the following: My Links: Link1 +show more links <!--- This is shown when...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.