[Maptool 1.6.1] new links created with javascript don't work?

Thoughts, Help, Feature Requests, Bug Reports, Developing code for...

Moderators: Azhrei, dorpond, trevor

Forum rules
PLEASE don't post images of your entire desktop, attach entire campaign files when only a single file is needed, or generally act in some other anti-social behavior. :)
Post Reply
Posts: 6
Joined: Mon May 23, 2016 4:51 am

[Maptool 1.6.1] new links created with javascript don't work?

Post by Findus »

I don't know if it's a bug or something that I did wrong, and I've not found anything related to it in the forums so I'm going to ask it in here.

I'm not a javascript expert but trying to make a new link inside a frame5 will make the link appear but it won't work.
Here's a very simple example,
the macro testJavaScriptLink :

Code: Select all

[h: sStr1 = macrolinkText("[email protected]")]
<!DOCTYPE html>
		function makeLink(elem){
			var oStr = elem.getAttribute('data-test');
			var oP = document.getElementById('idPar');
			var oA = document.createElement('a');
			oA.appendChild(document.createTextNode('New link!'));
			oA.title='A Title';
			oP.appendChild(oA);  <!-- This doesn't work! -->

			var oA2 = document.getElementById('pre-Link');
			oA2.setAttribute('href',oStr); <!--we change the pre-existing link and it work-->
	<title> Something </title>
		<p><a href='#' onclick='makeLink(this);' data-test='[r:sStr1]'>Make a link</a></p>
		<p id='idPar'></p>
		<p><a href=# id='pre-Link'>This link does not work</a></p>
and the macro marioTest :

Code: Select all

This code simply make a frame with 2 links, the first one call the javascript function, and the second one is broken on purpose.
The function will make a new link with a macro String, and also will put the same string in the broken link. The previously broken link will now work, while the newly made link won't work even with the same href.

Am i doing something wrong here?

Edit: Just for the sake of it I've even tried to pass the whole HTML code as a string and to write it in the frame using innerHTML, the link still appears but it still doesn't work.

Posts: 228
Joined: Wed Jun 05, 2019 7:06 am

Re: [Maptool 1.6.1] new links created with javascript don't work?

Post by Merudo »

Thanks for the report. It's a bug, and will most likely be fixed in 1.7.

Here is the github issue: https://github.com/RPTools/maptool/issues/1638

Post Reply

Return to “MapTool”