2

I just get a script from a website to put it on my own site, but it has a hyperlink on it and I want to disable that, here is the script:

<script language="javascript" src="http://www.parstools.net/calendar/?type=2"></script>

Thanks.

simbabque
54.4k8 gold badges77 silver badges141 bronze badges
asked Apr 20, 2010 at 3:55
2
  • Is the "hyperlink" you're referring to the script's src? That's how the script is loaded. What are you attempting to do by "disabling" it? Commented Apr 20, 2010 at 3:59
  • For those who don't want to open the src, it's one line: document.write("<a href='ParsTools.com/'>1389年1月31日</a>"); Commented Apr 20, 2010 at 4:14

5 Answers 5

2

Following from your previous question, you may want to try the following:

<!DOCTYPE html>
<html> 
 <head> 
 <title>Simple Demo</title> 
 </head> 
 <script type="text/javascript">
 window.onload = function () {
 document.getElementById('calendar').innerHTML = 
 document.getElementById('calendar_hidden').getElementsByTagName('a')[0].innerHTML;
 };
 </script>
 <body> 
 <div id="calendar_hidden" style="display: none;">
 <script src="http://www.parstools.net/calendar/?type=2"></script>
 </div> 
 <div id="calendar" style="color: red;"> 
 </div>
 </body> 
</html>
answered Apr 20, 2010 at 4:19
Sign up to request clarification or add additional context in comments.

Comments

1

If the link is always going to be the same, and you know how to get that string into a variable, this should work:

str = str.replace( "<a href='http://www.ParsTools.com/'>", '' ).replace( '</a>', '' )

Edit in response to comment

This isn't best practice, but.. Wrap the js include in a div:

<span id="whatever">
 <script type="text/javascript" src="..."></script>
</span>

Then

<script type="text/javascript">
 str = document.getElementById( 'whatever' ).innerHTML
 str = str .... // what i said before
</script>

This solution doesn't require jQuery, which it looks like you don't want to use.

answered Apr 20, 2010 at 4:02

5 Comments

yes the link is always going to be the same, but where I should add this: str = str.replace( "<a href='ParsTools.com'>", '' ).replace( '</a>', '' )
I've done this as far as I get you, see if I go wrong anywhere <div id="calendar"> <span id="whatever"> <script language="javascript" src="parstools.net/calendar/?type=2"> </script> <script type="text/javascript"> str = document.getElementById( 'whatever' ).innerHTML() str = str.replace( "<a href='ParsTools.com'>", '' ).replace( '</a>', '' ) </script> </div> thanks.
You don't need to put my script in the <div>, but it works as long as we're ignoring standards :) Don't forget to close the span as well! (between the </script></div>, you need </span>)
@user320946: I think you need to use the window.onload event, as in the example of my answer: stackoverflow.com/questions/2672421/…. Otherwise, the string replacement will happen before the external script is loaded.
thanks every one, Daniel way works just fine, and one more thing, I cant vote up yet, as far as I dont have enough reputation
0

I presume you mean the script creates a new hyperlink element on the page. You could simply write your own JavaScript (after the external script), which disables it. With jQuery that would be something like

$('#hyperLinkId').attr('disabled', true);
answered Apr 20, 2010 at 3:57

1 Comment

Thanks for your answer Evgeny, the script actually is a Calendar, and when I add this part to my page, it appears fine, but when you mouse over on it, it has a link to it's website (parsitools.net) and I want to disable that, and about jQuery, I really don't know anything about that and how I can add this to my page, I would really appreciate if you explain it much clearly for me, thanks
0

If you place that script inside of a <div id="something"> you can do the following:

var something = $('#something a');
something.replaceWith(something.contents());

assuming you include the jQuery library.

See "How to remove only the parent element and not its child elements in JavaScript?"

answered Apr 20, 2010 at 3:59

4 Comments

I put a div behind my script like this: <div id="calendar"><script></script></div> and where I have to put your codes then ? sorry for being so unfamiliar with jQuery
and also how can I add jQuery library to my page ?
You can download it from their website (jquery.com) or link a <script> tag to the Google-hosted version (code.google.com/apis/ajaxlibs/documentation/index.html#jquery). Since the code is so simple inside of the remote script you might be better off with a pure JS solution similar to hookedonwinter.
Check out jquery.com. Tons of very awesome documentation.
0

I had a look at the "script file" in question and i'm very confused.

This is the entire contents of the link: http://www.parstools.net/calendar/?type=2

document.write("<a href='http://www.ParsTools.com/'>1389年1月31日</a>"); 

It doesn't appear to be a calendar at all.

Can you provide more information regarding your using of this script file?

answered Apr 20, 2010 at 4:14

1 Comment

it's a calendar for some middle-east region actually

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.