I should write a script which should distinguish internal and external links with JS. The links can be absolute or relative. I thought the best guess would be to first check if it is a relative link by checking the first character of the string is a /. (but how do you do this?) Then it will be always an internal link.
Then I thought to check if the URL (this.href) starts with the current protocol + location.host . If YES, it is an internal URL, else it is an external URL.
So does anybody know how to check if a URL starts with '/' or '[URL]
I like having scripts external, but I wonder about the security of internal anyway. Someone could save and change the HTML, right? But is that possible with an external script? I always thought not (unless there was an error), until a person on this forum was able to grab the script I was working with at the time. No problem with that, but it brings up the question in my mind about security in general surrounding java-script.
I have a master.html where i have navigationDIV and bodyDIV, and on every click of nav tabs i am loading external html page into bodyDiv using following .load() function. $('#bodyDiv').load('home.html') Now I have some basic JQuery functions in external JS file which i have linked in master pagewhere i am using toggleSlide(), hide(), addClass() so and so forth, first time when page is getting load all these functions are working alright but the moment i am loading another tab page all functions stop working even on first tab also. Tab onClick script from where .load() function is getting fired:
I am using Toby's iKonize script and would like to add a little more functionality to the script but not sure how to.
I would like the script to find all external links and have them open in a new window, rather than setting the target, can this be achieved? Also, if the image could be added after the anchor so it doesn't get any of the styling associated with the anchor element.
So my regular link looks like this:
<li><a rel="external" href="http://www.google.com">Google</a></li> I need to figure out how to add the REL to the onclick in the LI <li onclick="location.href='http://www.google.com/';"><a rel="external" href="http://www.google.com">Google</a></li>
I can't seem to find any instructions about how to insert this REL option....
For example, you want to make different all links (a tags), which href attribute is set to external site. So I wrote a small piece of JQuery code, which add class, to all external links.As bonus it's also do shortening of long URLs in link text.
Disclaimer 1: I am not a programmer, just a curious designer, so please take that into consideration in your replies.
Disclaimer 2: Despite all advices against it, I couldn't find a better solution to my website than using iFrame
Disclaimer 3: Before asking for help, I researched *several* forums and although I found people discussing similar issues,
implementing a method to intercept and redirect external links to a dynamic iframe. By "dynamic" iframe I mean an iframe whose SRC would be filled up in accordance to the external URL being intercepted and that it would resize its HEIGHT accordingly in order to avoid scroll bars.The function for resizing the iframe id="child" is already correctly implemented like so:
This "replacement" function would be called onLoad and if tested true would run and refresh the page with the proper value in the iframe SRC.All this should be accomplished while still making the iframe HEIGHT dynamically adjustable and show a "clean" URL in the browser, such as "http:[url].....The potential issues I foresee is an infinite loop due to two onLoad queries (one for SRC, another for HEIGHT) in the parent and child objects, which might required a merge into a single script.
I have an external JS file with an array of menu links called (menu.js).
The code is shown below:
The html code is shown below:
My site pages are now html4/strict so I used the "function externalLinks" script found here [URL]. I followed the instructions carefully, made sure I copied the script shown to the external.js file and uploaded it into the same directory as the html files. Also made sure that external.js was called as required in the head. Also made sure all target="_blank" were changed to rel="external" as required. Unfortunately, it doesn't work. The link takes the visitor outside my site, instead of creating a new window. I don't get it. Here's one of my pages ... [URL]
If you click on the Retaining Walls link, it will direct you to a new page and the anchor will be highlighted. The issue is that if you attempt to click on Drainage or Design/Build, then it will not scroll up to the anchor.Other than that, if you were already on that page, then the anchors and scroll works fine. Is there something I can do to fix it?
I am in a bit of a rut in the self-teaching with JS. I am trying to get links to change the external js file currently on the main page without reloading, the external files are basically long document.write sections with a few interactive functions.
The closest I have found for help with this so far is a rotating script, but I want a manual change from a link (button, image, etc) instead of timeOut rotation. I am not sure what I need to do for the links to replace the timeout function to change the dynamic section.
I have the existing code that will change all my links to external sites to open in a new window. I now want to change it to allow me to have a way that it will not do this if I put something special in the a href tag.
I have the following problem:
For my application, I need to ask a confirmation when the user closes the browser-window. If the answer is positive, I would like to log-off the session and close the window. If the answer is negative, I would like to stay back (no logging-off, no closing the window).
I can't do this in the window.unload event because the window is already closed when the unload event is fired. I tried doing this in the beforeUnload event. But the beforeUnload event gets called even when I refresh the page and in that case, I don't want to ask this question or logoff.
I really don't know if this is correct but it works! What doesn't work is the active class. If you use one of the buttons in the first tab you go to the right tab but the tab itself has no class called active and that ruins the style.
2) I also have one other question: lets say that all the above is my second page and I have my frontpage in which I also have buttons. I want somebody to use the button and end up in the third tab of page 2. My link is something like
I read that using this should lead you the third tab but it's not working for me. You go to the first tab of page 2 instead.
I've been reading a LOT! Jquery for dummies, I googled, read the forum and other forums. I posted on a Dutch forum but no answer. I've added a lot of different code but it doesn't work.
I have to open a new window when user closes the browser window. But the problem is that on browser close unload event calls and the same event is called with we refresh the page. So it is opening the popup window on both window close and window refresh.