Trying to make a "on-hover image" BB code

Get help developing custom BBCodes or request one.
rudi_br
Registered User
Posts: 99
Joined: Sun Dec 10, 2017 5:48 pm
Name: Rudi Bjørn Rasmussen

Trying to make a "on-hover image" BB code

Post by rudi_br »

I am trying to implement BB code, that can be used to display an image and an other image on mouse hover.

I've tried this, but that doesn't work at all.

BBCode usage:

Code: Select all

[himg={URL1},{URL2}][/himg]
HTML replacement:

Code: Select all

<a href="{URL1}" 
onMouseOver="if (document.images)document.imagename1.src='{URL1}';"
onMouseOut="if (document.images)document.imagename1.src='{URL2}';">
<IMG SRC="{URL2}" name=imagename1 style="max-width:100%"></a>
I am not sure, if I can access document.images from BBCode. Any ideas? Should I try another approach?
Last edited by Mick on Tue Jan 18, 2022 1:10 pm, edited 2 times in total.
Reason: Solved
/Rudi Bjørn Rasmussen
User avatar
Mick
Support Team Member
Support Team Member
Posts: 26848
Joined: Fri Aug 29, 2008 9:49 am

Re: Trying to make a "on-hover image" BB code

Post by Mick »

This should be in the custom BBCode forum, I’ll move it for you.
  • "The more connected we get the more alone we become” - Kyle Broflovski© 🇬🇧
rudi_br
Registered User
Posts: 99
Joined: Sun Dec 10, 2017 5:48 pm
Name: Rudi Bjørn Rasmussen

Re: Trying to make a "on-hover image" BB code

Post by rudi_br »

Thanks Mick. And sorry
/Rudi Bjørn Rasmussen
User avatar
pit-PL
Registered User
Posts: 3212
Joined: Sat Nov 21, 2009 12:24 pm

Re: Trying to make a "on-hover image" BB code

Post by pit-PL »

Try [himg]{URL1},{URL2}[/himg]
rudi_br
Registered User
Posts: 99
Joined: Sun Dec 10, 2017 5:48 pm
Name: Rudi Bjørn Rasmussen

Re: Trying to make a "on-hover image" BB code

Post by rudi_br »

Thanks for the advise. I tried that, but now the preview shows a "broken image icon".
/Rudi Bjørn Rasmussen
User avatar
pit-PL
Registered User
Posts: 3212
Joined: Sat Nov 21, 2009 12:24 pm

Re: Trying to make a "on-hover image" BB code

Post by pit-PL »

Put a space before and after ,.

Code: Select all

[himg]{URL1} , {URL2}[/himg]
rudi_br
Registered User
Posts: 99
Joined: Sun Dec 10, 2017 5:48 pm
Name: Rudi Bjørn Rasmussen

Re: Trying to make a "on-hover image" BB code

Post by rudi_br »

Thanks, that did the trick.
The BBCode is very sensible to the spaces and comma, the image url's must be separated by " , " and then it works!

Code: Select all

[himg]https://myforum.com/image1jpg , https://myforum.com/image2jpg[/himg]

Demo here:
https://www.astronet.dk/forum/viewtopic ... 491#p36491
/Rudi Bjørn Rasmussen

Return to “Custom BBCode Development and Requests”