Extract Links From Javascript (not Using Javascript)?
May 26, 2006
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 tailored
to a particular page/script.
Hopefully, the problem can be solved without recreating a complete
Javascript interpreter. Any ideas?
just seen a javascript menu I like on this website - [URL]....dex.php?act=idx and was wondering if there was any way of copying it? If not, then does anyone know where I could get a similar menu?
I'm using the lightbox gallery (http://www.dynamicdrive.com/dynamicindex4/lightbox2/index.htm) script from dynamic drive to sample images for sale on my website. I need to be able to add a "Click to buy" link in the actual popup image which will divert them to my order system. It has to be done this way so I know which image they have ordered.
I'd like to add the image in the bottom left section where you can put an image description.
I wrote a funtion for all my <a href=...> tags. If I use the function, it looks like this: <a href="test.html" onFocus="myfunction()">
What I want is to automatically add myfunction() to all the links on a page. So I don't want to add onFocus=blablabla each time when I link to another page.
Although I am able to drag and drop HTML links, I am no longer able to drag Javascript links.
In the past, I have been able to drag a link from such places as the TinyURL! link on http://tinyurl.com to my Links Toolbar. Now I can't. When I try to drag any Javascript link, my cursor does not change the same way it does for an HTML link. I see a hand icon for both link types. When I try to drag a Javascript link, it changes from a hand to an arrow as soon as I pull the cursor away from the link.
Is this problem new to WinXP SP2? Has one of my settings changed? Has Norton Internet Security become more actively involved?
I had this idea to implement on the Kid's Activities page on the website for work and after hours and hours and hours of laboriously slaving over code (yeah, right... more like an hour, most of which was spent formatting and commenting the code) I just had to share it with people.
Really, it's not that long but it's pretty well documented throughout and adhears to the PHP/PEAR formatting rules so it looks rather spread out. The code itself probably isn't as streamlined as it could be, either... the "?:" operator instead of an IF-THEN statement and the FOR statement instead of WHILE-LOOP help, but there's always extra tweeks that could be made. I wanted to get the idea out there, though.
I've also posted the code on the cyberdevdigest website at cyberdevdigest.com/code/javascript/rainbow_links.html (http://www.cyberdevdigest.com/code/javascript/rainbow_links.html).
// declare list of colors as a global array (goldenrod used // because yellow was too difficult to against lighter // backgrounds) var colors = Array('red', 'orange', 'goldenrod', 'green', 'blue', 'purple');
// declare color pointer (current color in array by position) var p_color = 0;
function strobe(x) { // set pointer to next color (reset pointer to beginning // if current position is at the end of the list) p_color = (p_color == 5) ? 0 : p_color + 1;
// set link color document.links[x].style.color = colors[p_color];
return true; // no errors }
function rainbow(link, toggle) { // determine which link called this function by matching // the current key of the DOM's link array for (id = 0; link != document.links[id]; id++);
if (toggle) { // identify setInterval function by name cycle and // repeatedly call change_color passing current link // array key cycle = setInterval('strobe(id)', 100); } else { // terminate cycle calls clearInterval(cycle);
// reset link color (assuming that green was original // color) link.style.color = 'green' }
return true; // no errors } //--> </script>
call using onmouseover and onmouseout event handlers, such as in this example:
I'm working on a project where we're using JavaScript to let users swap styles on a page. To accomplish this, I'm calling the script via href="javascript:swapcss()" on the switch styles button.
Some pages on the site have anchor links. On those pages, if someone swaps styles without hitting any of the anchor links, all is well. But if someone hits an anchor link and then hits the swap button (at this point the URL is pageid.html#anchor), the page just reloads to their anhor point without swapping styles.
Does anyone have a workaround handy? I've tried several alternatives I've found online (href="#" onClick="action"; href="javascript void(0)" ). Nothing works for this case yet. Code:
I have a DHTML Folder Tree, also known as a TreeView. That is, an expandable/collapsible tree of links. In a frame-less layout everything works great. In a frame-based layout, it doesn't work on Safari/Konqueror.
There are two frames: the left frame contains the tree control; when you click on a link in the tree, the right frame is the target for the links in the tree.
The tree mechanism itself works fine. But there is a problem with the links. What happens on Safari/Konqueror with the frame-based layout is the first link works fine, but all links after that do not. That is, the first click loads a picture on the right frame, but when I click on any other links after that, the target frame is not updated.
I'm working on some code and am running into brick walls. I'm trying to write out Javascript with Javascript and I've read the clj Meta FAQ and didn't see the answer, read many similar posts (with no luck though), and searched through the IRT.ORG Faqs (www.irt.org/script/script.htm).
The Javascript is designed to open an popup window and then inside that window call another script which will resize that window. There may be another way around this but the reason I tried this approach initially was that I wanted to call the onload handler in the popup window to resize the image only after the image had completely loaded. I've had some code in the primary Javascript file (showimage.js) before that works if the image has been cached but on the first load, it doesn't resize properly which tells me it is probably because it is trying to resize the window based on the image size but it isn't completely known at that point. So I removed that code and tried placing the resizing code in the second Javascript file (resizewindow.js). BTW I've tried other code to open a popup image and automatically size it ie Q1443 at irt.org but that doesn't do exactly what we need.
Even if there is another way to do this with one file, I still want to figure out why this isn't working in case I run into it in the future.
I thought what I would need to do to use document.writeln to write Javascript would be to escape any special characters and to break apart the script tag ie
document.writeln('</SCRIPT>');
would become
document.writeln('</SCR' + 'IPT>');
I have a HTML page and 2 Javascript files. All files are in the same directory and have permissions set correctly.
Here are the 3 files (keep in mind wordwrap has jacked up the formatting):
index.html ---------- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Test</title> <SCRIPT type="text/javascript" LANGUAGE="JavaScript1.1" SRC="showimage.js"> </SCRIPT> </head>
<body> Click the house<BR> <A ONCLICK="newWindow1('house1.jpg','Nice House')"><IMG SRC="house1thumb.jpg"></A> </body> </html>
showimage.js ------------ function newWindow1(pic,sitename) {
resizewindow.js --------------- function resizewindow() { // Do resizing here. // Right now this isn't being executed alert("resizing window"); }
Can anyone provide some pointers as to why this javascript is failing? I'm using IE6 on Win2k and when I click on the image to open the popup window, it does open the window but it is white with no content and the system immediately goes from about 4% CPU usage to 100% and consistently stays there until I kill that window with the task manager.
Attached is a simple HTML file that adds and delete rows. In the add row function I set an attribute "onClick" this triggers the testMessage() function. When I try this in Firefox it works just fine however on IE it just refuses to work.
What is interseting is the ROW that already exists has a similar 'onClick' event which works when the page is loaded, but subsequent "row" additions to the table to not work in IE. Code:
I'm getting errors in Firefox everytime I try to run this frame resize code, but it works fine in IE. I can't seem to figure out what the problem is with it.
The error is: Error: theFrame has no properties Line: 8
The line that the javascript console is showing an error for is in italics.
I'm already past the basics of Javascript, and i need something that takes me to the other level and teaches me the new technologies and cool stuff (drag&drop, AJAX, OOP in javascript, maybe XUL...etc). So far i found these two books:
1. Sitepoint's "The JavaScript Anthology: 101 Essential Tips, Tricks & Hacks". 2. Worx's "Professional JavaScript for Web Developers (Wrox Professional Guides)"
Both seems to cover very insteresting topics, but i can only buy one of them. So which one do you suggest?
and by the way, i've read the sample chapter 5 of Sitepoint's book, and it seems like the author(s) just put the solutions/codes there and let you figure them out on your own. Is this how the rest of the chapters are?
This is a question about defensive web browsing. Ocassionally I run into a page whose JavaScript does something that I find obnoxious. I would like to turn off JavaScript only for that page (instead of disabling it globally). It would be cool if there were some way to do this through a "bookmarkable" JavaScript snippet using the javascript: pseudoprotocol. Does anyone know any trick to do any of this?
I have some javascript that I have written into the <body> section and it works great. But I would like to make it into a javascript function and define the function in the <head> section. Then in the <body> section write a small bit of javascript that would call the function() object. Code:
I would like to know how to write javascript such that, a part of it isnt considered as script, & rather as HTML. Code:
Ok, the layer div can be written using document.write. But, Google ad itself is a javascript isnt it. How can it be written into this? How does this work?
Ok so, this is my purpose: - to be able to load asynchronously (via AJAX) some javascript ads (like google's or adbrite) so as to make them be loaded in the background, then update the page after the ads have loaded via innerHTML
Why? -Because 90% of the time in my newer sites, javascript ads are the major offender in terms of speed of page rendering
My problem: Via ajax, I can call a php file that retrieves some javascript and outputs it, XMLhttprequest returns those javascript lines, but they don't render in the page, since they miss the whole page loading, and are apparently not parsed For example, let's say I call a php file via ajax, and it returns the output into a variable named "text" containing "document.write('hello')" if I use xxx.innerHTML=text, nothing happens
My 1st solution: Passing those javascript lines to eval() [like eval(text) ], but this produces a second problem, that I couldn't solve (probably because of my lack of knowledge in javascipt): if I eval the code, it deletes my current page and renders a new one for example, if I parse a document.write, my page disappears, and a new one is rendered with the document.write text
What I want is basically to make that "document.write" appear inside a div in my page, adding to the content (and not overwriting the whole page), much like what happens when using innerHTML
Is this even possible? How would you go about it? I tried xxx.innerHTML=eval(outputfromphpfile) but it overwrites my whole page...
Just a quickie: is it possible to place javascript within javascript? The following is the code I am using to create a pop-up for a picture gallery. I would like to place a banner from a banner exchange in bold under each photo. When I use the code below I get an error message:
Basically, on one of my sites I'm running adsense and today I added Chitika. The problem is, I can't run those type of ads through my banner advertising program.
The banner advertising program calls the banners/HTML from code like this:
And using that program I'm able to either choose a banner or HTML I want to display when that code above is used. It displays HTML ok... but when I try to run an ad of either adsense or chitika nothing displays on the page. The code that would be called is:
So... it looks like I can't have javascript call another javascript to display on a page. My question is then... how can I edit the above to make it work or how can I work around this problem? I'd really want this to work with Chitika and not so much with adsense... but it appears both Chitika and Adsense use similar javascript code.
I am new to jquery, and love it so far, but I am more of a designer, not a developer. I am learning jquery to enhance my sites, and I am having a problem figuring out buttons.
I have them working in firefox and safari, but in IE links do not work.