Consider velcro tape. Stick the soft side on your tablet/laptop and the 'catchy' side on a part of the treadmill. I have done for my phone on my car dash and it works like a charm.
You will have to consider the weight of the tablet, and have a protective cover in case it falls off.
If your equipment is expensive, consider the gooseneck for peace of mind.